0
votes

Has anyone else experienced this before and know of a way to fix it? I'm working on PHP files which have inline HTML within the PHP code as follows:

<?
$html = '<html>'.$moreCode.'<head></head><body>'.$bodyCode.'</body></html>';
?>

Obviously this is a snippet of the real code - the file I'm working with is only 500 lines of code in total.

I'm finding that when I scroll through the file or try typing code anywhere in the file, the entire PhpStorm session pauses and resumes a second or two later. This is happening on every keystroke. The only workaround so far I have found is not to use HTML within PHP.

Inspections are all disabled. I tried enabling "Power Saving Mode" too but to no avail.

I am using PhpStorm 8.0.3 on Windows 7 Ultimate SP1 x64; Intel i5-3470 3.2GHz, 8GB RAM, SSD HDD. The file I am working on is network based, accessed on a Gigabit ethernet connection.

I would really appreciate any feedback, suggestions or solutions.

Thanks in advance.

1
Have you tried JetBrains support? - vascowhite
Such slowness may happening because of your code which (if all lines are like this) has lots of injected languages fragments (in your single line you have 3 fragments). Try disabling HTML Language Injection (Settings | Editor | Language Injections) -- any better? "The file I am working on is network based, accessed on a Gigabit ethernet connection." This also may be a problem as IDE requires really fast access to source files and may produce such random "freezes" it latency is too high for it. Try opening this file from local HDD/SSD -- any better? - LazyOne
Disabling lanaguage injections has cured it, thanks. If you can post this as an answer, I'll accept it as the answer (and you'll get the points). Thanks again. - Reado

1 Answers

1
votes

The slowdown could be because of your code -- heavy mix of HTML and PHP (especially if HTML code is done via echo/print statements and alike -- in such case IDE will inject HTML language in such fragments .. which makes it slower).

Your example (single line) has 3 injected fragments. If you have plenty of lines like that -- it will definitely make IDE slower.

  1. You may try embed variables into actual string instead of concatenating, e.g.

    $html = "<html>{$moreCode}<head></head><body>{$bodyCode}</body></html>";

    This will make 1 injection fragment instead of 3 separate ones.

    The negative moment here: you need to modify your code.

  2. Or you can just disable HTML Language Injection rule altogether at Settings | Editor | Language Injections.

    Good part: no need to modify your code.

    The negative moment is that doing this will affect all projects as this is GLOBAL rule (and your only choice if you still want having it in another project would be making a copy of such rule and enabling it for that specific project only).


P.S.
In PhpStom v9 (currently at EAP stage) you can forcibly disable language injection via PHPDoc style comment placed before actual string, e.g. $html = /** @lang text */ '<html>'.$moreCode.'<head></head><body>'.$bodyCode.'</body></html>';