S
S
Shyrick2015-03-05 19:03:25
phpstorm
Shyrick, 2015-03-05 19:03:25

How to setup persistent language injection in strings in PhpStorm?

I will describe the essence of the problem: if the php string contains valid html / js without breaking this string for concatenation with other variables , then PhpStorm highlights the syntax as expected. But if you try to compose a "html" string from several, the highlight disappears. In search of a solution to the problem, I came across a php developer blog in which he described PhpStorm, I will quote with a screen$var = '<a href="#">link</a>'$var = '<a href="' . $link . '">link</a>'

Often in Bitrix you have to see porridge from html / js / php (and sometimes even sql code)? Moreover, jquery can be actively present in the file, and php code is sometimes written using an alternative syntax for control structures? Then you will appreciate how the editor does a great job with this mess! He also knows how to mix languages, for example, when you generate some js or html code using php, the generated fragment will have syntax highlighting, as well as an assistant for compiling language inserts.-%D0%B2%D1%81%D1%82%D0%B0%D0%B2%D0%BA%D0

The screenshot shows how PhpStorm (on the right) highlights the concatenated $fieldValue string.
In my case it turns out like this 43e414e6793941d98350412b266cec9c.png
Tell me what settings are responsible for this? Very annoying :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
mmjurov, 2015-03-07
@Shyrick

If you have a fresh version of the storm, then Language Injection comes out of the box. If not, then you need to install the IntelliLang plug-in.
The settings for language inserts themselves are here - File | settings | editor | Language Injections
In general, all this is described in the official JetBrains manual, and as the author of that same "php developer's blog" I did not think that there could be problems with the activation of this functionality.
UPD . Brad wrote .. in the evening my head doesn’t boil much.
Specifically, in your example, Alt + Enter should help. It will inject the entire string.
By the way, for what is shown on the right screen, I didn’t set anything up on purpose, somehow it worked out of the box :)
Here is the GIF
The truth in some places for some reason does not work. I can simply drag this piece of code to the top of the file and can no longer insert the language - the choice in the panel from Alt + Enter is not available

A
asdz, 2015-03-05
@asdz

Oh, this Bitrix... even PHPStorm can't handle it. In such cases, perhaps Alt + Enter can help?

O
obemgcabazn, 2020-06-01
@obemgcabazn

Settings - Editor - Color Scheme - General - Code - Injected language fragment - Uncheck Background

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question