简体   繁体   English

Netbeans语法高亮显示伏特(twig)和phtml文件中的PHP

[英]Netbeans syntax highlighting for volt (twig) and php in phtml files

I'm working with Phalcon in Netbeans. 我在Netbeans中与Phalcon合作。 I see I can use twig plugin for template highlighting for volt files. 我看到我可以使用twig插件来模拟高压文件。 I am using phtml files and want highlighting for volt (twig) and php. 我正在使用phtml文件,并希望突出显示伏(twig)和PHP。 Is this possible? 这可能吗?

Also related - Netbeans keeps duplicating my phtml view files and adding the extention .phtml.php to them. 也相关 - Netbeans不断复制我的phtml视图文件并将扩展名.phtml.php添加到它们。 How can I fix that? 我该如何解决这个问题?

Go to Tools->Options->Miscellaneous->Files right to "File Extensions" press "create" and type there "volt". 转到工具 - >选项 - >杂项 - >文件右转到“文件扩展名”按“创建”并键入“伏特”。 After that in "Associated File Type (MIME)" choose "TWIG (text/x-twig)". 之后在“关联文件类型(MIME)”中选择“TWIG(text / x-twig)”。 Restart IDE. 重新启动IDE。

I use twig syntax in PHPStorm and everything works fine. 我在PHPStorm中使用twig语法,一切正常。 Look at Netbeans settings(or the twig plugin settings) and try to add new file extensions to be recognized as twig files like *.volt and *.phtml . 查看Netbeans设置(或twig插件设置)并尝试添加新的文件扩展名,以识别为*.volt*.phtml等文件。 If you can't figure out how to make volt files be recognized as twig files, as a last resort, you can change all you template files to .twig then change Volt settings to recognize .twig files as a Volt template, like: 如果您无法弄清楚如何将伏特文件识别为twig文件,作为最后的手段,您可以将所有模板文件更改为.twig然后更改Volt设置以将.twig文件识别为Volt模板,如:

//Registering Volt as template engine
$di->set('view', function() {

    $view = new \Phalcon\Mvc\View();

    $view->setViewsDir('../app/views/');

    $view->registerEngines(array(
        ".twig" => 'Phalcon\Mvc\View\Engine\Volt'
    ));

    return $view;
});

About .phtml.php isn't Netbeans creating these files, it's Phalcon. 关于.phtml.php不是Netbeans创建这些文件,它是Phalcon。 All templates are compiled to .php . 所有模板都编译为.php They will be put in the same folder of your template unless you configure your Volt engine properly. 除非您正确配置Volt引擎,否则它们将被放在模板的同一文件夹中。 More info about this here . 有关这方面的更多信息

Go to Tools->Options->Miscellaneous->Files. 转到工具 - >选项 - >杂项 - >文件。 Click New "File Extensions" and type there "volt". 单击新建“文件扩展名”,然后键入“volt”。 After that in "Associated File Type (MIME)" choose "TWIG (text/x-twig)". 之后在“关联文件类型(MIME)”中选择“TWIG(text / x-twig)”。 Restart IDE. 重新启动IDE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM