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

痞子三分冷 提交于 2019-12-09 13:17:17

问题


I'm working with Phalcon in Netbeans. I see I can use twig plugin for template highlighting for volt files. I am using phtml files and want highlighting for volt (twig) and php. Is this possible?

Also related - Netbeans keeps duplicating my phtml view files and adding the extention .phtml.php to them. How can I fix that?


回答1:


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)". Restart IDE.




回答2:


I use twig syntax in PHPStorm and everything works fine. 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. 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:

//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. All templates are compiled to .php. They will be put in the same folder of your template unless you configure your Volt engine properly. More info about this here.




回答3:


Go to Tools->Options->Miscellaneous->Files. Click New "File Extensions" and type there "volt". After that in "Associated File Type (MIME)" choose "TWIG (text/x-twig)". Restart IDE.



来源:https://stackoverflow.com/questions/23846514/netbeans-syntax-highlighting-for-volt-twig-and-php-in-phtml-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!