PHPStorm: Syntax Highlighting for PHP code inside XML tags

最后都变了- 提交于 2019-12-18 09:44:33

问题


Is there any way to make PHPStorm apply syntax highlighting to PHP code inside a tag in an XML file?

I'm working on an OpenCart project and I'm using Vqmod, which requires that I write PHP code in an XML file. For example:

<operation>
    <search position="replace"><![CDATA[
        <?php echo "123"; ?>
    ]]></search>

    <add><![CDATA[
        <?php echo "xyz"; ?>
    ]]></add>

</operation>

回答1:


1) Settings | File Types -- assign *.xml (or whatever file name pattern you think is more appropriate) to PHP files entry (you may need to remove it from "XML files" first).

This will tell PhpStorm to treat such files as PHP (it's the only way to have PHP support).

The possible negative side -- it's an IDE-wide setting and will affect ALL such files in ALL projects. Therefore -- if you can name such files in some unique way (e.g. double extension: *.php.xml or *.xml.php; unique extension: *.pxml; unique file name ending: *layout.xml) then do it.

2) Settings | Template Data Languages -- find such files (or whole folder) and assign XML in 2nd column.

This will tell PhpStorm to treat such files as "PHP with XML" instead of default "PHP with HTML".


Official manual: http://confluence.jetbrains.com/display/PhpStorm/Syntax+highlighting+of+PHP+inside+JavaScript+%28and+other+languages%29



来源:https://stackoverflow.com/questions/18101130/phpstorm-syntax-highlighting-for-php-code-inside-xml-tags

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