PHPStorm, sad and frustrated first time expereinces [webserver, language injections]
Hello everyone, glad to be here and talk to professionals of php world.
I started my journey into php language from selecting good IDE and because of friend's advice my choice fall onto PHPStorm.
I gave a good try for 2 days and 10-12 hours total in trying to get everything i want with PHPStorm but still unable to find out how some feautures work.
1st problem is with language injections. Steps to reproduce:
1. Open html document with simple structure > html + head + body
2. type in any tag : p , div, pre.
3. Put cursor inside of that tag and press Alt + Enter -> select any language injection
4. Now if you delete tag or create any new tag or copy/paste some php code editor will show green/yellow blocks of code inside of any tag and paste empty lines instead of php code. Syntax highlighting won't work either in this green blocks.
You can't get rid of that behaviour in any way except using Ctrl + Z right in time to undo changes. If you save or reload document - you lose your way back forever.
Pressing Alt + Enter show's nothing like "Uninject language code". This menu item only appears if you inject language inside quotes("" , '') for me.
I wasted so much time on trying to figure it out and still i am unable to deny/undo this injection.....
2nd problem is with built-in web server. I have specified php interpreter and configured php.ini and all looks good in settings.
But it works very strangly. Some files are opening correctly, some throws 520 bad gateway. One very strange behaviour - after i try to open files that will fail to launch, every other working before files won't launch, so web server simply freezes.... I stop any other web servers i have on my pc as well as allowing any connections in my firewall settings(simply disable firewall).
请先登录再写评论。
Hi there,
>You can't get rid of that behaviour in any way except using Ctrl + Z right in time to undo changes. If you save or reload document - you lose your way back forever.
"Settings (Preferences on macOS) | Editor | Language Injections" and look for entries with "Project" or "IDE" values in the Scope column. Delete unwanted entry.
P.S. Un-injecting via Alt+Enter works just fine for me in <p>aa</p> fragment.
>Some files are opening correctly, some throws 520 bad gateway.
Yes, built-in simple web server can show 502 error for no apparent reason for a perfectly valid code. The same code can work for one person/setup and will fail for another. Please follow https://youtrack.jetbrains.com/issue/WEB-31859
Workaround --- use proper webserver (Apache/nginx/IIS/whatever). If you rely on "Open in Browser" kind of actions in IDE, you need to define deployment entry, specify your website URL there and mark that entry as Default for this project. Without it those action will use built-in webserver URLs.
> "Settings (Preferences on macOS) | Editor | Language Injections" and look for entries with "Project" or "IDE" values in the Scope column. Delete unwanted entry.
P.S. Un-injecting via Alt+Enter works just fine for me in <p>aa</p> fragment.
looking for scope items with IDE and Project helped me, thanks a lot. But Uninjecting menu item still not showing for me. Anyway i can manage it via scope column.
Follow https://youtrack.jetbrains.com/issue/WEB-31859
thanks again, i will take a look. and thanks for tip about defining default webser for "Open in Browser" feature that was exactly what i wanted
>But Uninjecting menu item still not showing for me. Anyway i can manage it via scope column.
Code:
Some language (JSON in my case) was injected into that tag (so content of all <p> tags is treated as JSON).
Caret is between "aa" letters -- <p>a[CARET]a</p> -- Alt+Enter works just fine for me (Windows 10, PhpStorm 2019.2.4, bundled x64 JRE)