I'm working on OpenCart project now, which intensely uses XML-configs for extensions (called OCMOD).
XML config is the mix of declarations with injections of PHP/CSS/JavaScript code, see part of real OCMOD modification file below:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>some name</name>
<id>some ID</id>
<version>some version</version>
<code>some code</code>
<author>author</author>
<link><![CDATA[link]]></link>
<file path="catalog/controller/product/product.php">
<operation>
<search><![CDATA[
$product_info = $this->model_catalog_product->getProduct($product_id);
]]></search>
<add position="after"><![CDATA[
// some PHP code here
$s = 'hello world';
echo $s;
]]></add>
</operation>
</file>
</modification>
I use PHPStorm 2019.2 for development. By default it's bundled with plugin to inject code into source files.
Are there any techincs to achieve syntax highlighting for injections into XML-code?
P.S. I've found this answer, but it doesn't fit my needs because PHP-injections in my file don't have <?php
and ?>
tags.
The file must be associated with "PHP File" file type in order for PhpStorm to provide PHP support in such file. You cannot take a random file and say "this section from here to there is PHP" as PHP support does not have "PHP as Injectable Language" implementation in IDE yet. Your file has no PHP tags (<?php ... ?>
) therefore standard thing with Template Date Language will not help here.
Next 2019.3 version of PhpStorm will come with Injectable PHP. ATM I do not know if that will work for your example (and how it works overall); based on existing tickets it meant to be injected into other literals that are already using PHP code: e.g. eval()
, PHP blocks in Markdown and stuff like that. Need to wait for 2019.3 EAP program to start and only then try it.
Right now this ticket seems to be an exact match for your needs: https://youtrack.jetbrains.com/issue/WI-47857 -- watch it (star/vote/comment) to get notified on any progress.
It refers to a similar cases like yours (see github.com/Combodo/iTop).
Feel free to comment there with your examples (so devs know that there is a demand for such feature).