1

I am very new to PhpStorm. I have joined a team and started working on a new feature, but found that part of my file is now without the different colors that are usually shown for PHP. It has a background, which I removed, but the text is plain white (instead of orange, yellow, etc.). I am not sure what I did or how only part of the file is like this and the rest is fine, but any help would be appreciated.

The file is PHP and has some HTML in it. Apart from this one part, everything else has the correct background and the correct coloring.

I tried invalidating the caches and restarting and that helped for a minute or two, but when I switched to something else and then back again, the problem was back. Any help would be much appreciated.

screenshot

IDE window screenshot

IDE

PortyR
  • 355
  • 1
  • 2
  • 12
  • Can you go to `File->Settings->Editor->Code Style` And check the `PHP` settings. Also, in the same location I mentioned above, check the `Color Scheme` (I use Dracula for example). Another thing it usually happens is using `die()` in the middle of the `PHP code` has it will blank all the lines after the `die` is used to make us aware something is stopping the process after that line – Diogo Santo Nov 19 '18 at 09:52
  • 1
    Also, if you are able, can you confirm if when on a `.php` file type, if `phpstorm` will ask you to `install php plugin`? It might be possible it is disabled or needs updating for some odd reason – Diogo Santo Nov 19 '18 at 09:55
  • Thank you for your response. I also use Darcula as my theme. – PortyR Nov 19 '18 at 10:31
  • There is no die() in the script. I will check the php plugin. – PortyR Nov 19 '18 at 10:32
  • Please provide a screenshot. Otherwise it will be just guessing... – LazyOne Nov 19 '18 at 10:35
  • I cannot find any problems. I am not sure how to check the php plugin. – PortyR Nov 19 '18 at 10:36
  • It's a php file. Maybe part of it got marked as phtml? How would that happen and how would I change it back? – PortyR Nov 19 '18 at 10:41
  • @RivaPortman I believe you can just `right click` and change the `extention` of the file if such is the case. `PhpStorm` can pick it up. I also found a interesting post [here](https://stackoverflow.com/questions/4306182/wrong-syntax-highlighting-for-php-file-in-phpstorm) that might help you out – Diogo Santo Nov 19 '18 at 10:45
  • Thank you, Diogo – PortyR Nov 19 '18 at 10:46
  • Thank you, but it is still not working. I restarted PHPStorm and everything looked great for about 3 seconds, then it went back to the way it was. – PortyR Nov 19 '18 at 11:06
  • are you using Html coding and then directly start coding with php if your are doing this then you need put your all codes in @PHP. – Ashish Nov 19 '18 at 11:09
  • The existing file was php. I didn't edit any of the HTML in it, just made a few changes in the php parts. – PortyR Nov 19 '18 at 11:25
  • 1
    I want to see whole IDE window, especially file icon for this file. Right now it could be 2 possible reasons... – LazyOne Nov 19 '18 at 12:56
  • Sorry for the delay in responding. I was at work at got busy with other stuff. I will try and upload a picture of the whole IDE window now. – PortyR Nov 20 '18 at 13:34
  • the IDE window does show a .php file - however it's not formatting the PHP code as expected. Leading my to believe you've changed the associated language with the file ending.. are you able to do a vanilla install of PHPStorm at all and try there? – treyBake Nov 20 '18 at 13:41
  • I don't know how to do that. I am actually taking a few days off tomorrow, so I will look into that when I get back. Thank you for the responses. – PortyR Nov 20 '18 at 14:25
  • *" It has a background, which I removed,"* this .. would be good to know what background it had. Any way, please post screenshot of `Settings/Preferences | Editor | Language Injections` -- I'm interested in "IDE" in "Project" entries only (for the "Scope" column) – LazyOne Nov 20 '18 at 23:33
  • I see it is highlighting method calls like `->format`. Please post a screenshot of your `File > Settings... > Editor > Color Scheme > PHP` panel. You also might be able to revert to the default Darcula scheme by selecting "Default", Apply, Close and re-launch PHPStorm and then repeat the process for "Darcula". – Will B. Nov 20 '18 at 23:48
  • @LazyOne, I will add the screenshot now. – PortyR Dec 02 '18 at 07:55
  • @fyrye, I tried that, but it didn't help. The text is still white. – PortyR Dec 02 '18 at 07:57
  • @RivaPortman Delete those 2 Language Injection rules (well, disable first, ensure that it's all good now and then delete). – LazyOne Dec 02 '18 at 11:40
  • @LazyOne, thank you so much! That worked! – PortyR Dec 02 '18 at 12:05

1 Answers1

0

I see 3 main possible reasons:

  1. This file is not treated as PHP by IDE (e.g. associated with just HTML/Plain Text or some another file type). For that I need to see file icon (ideally whole IDE window, just in case).

  2. You have accidentally injected another language somewhere in the file, so that part is now treated as plain text instead of PHP. For that I need to see the screenshot of Settings/Preferences | Editor | Language Injections -- I'm interested in "IDE" in "Project" entries only (for the "Scope" column).

  3. Some plugin interference. For that you would need to provide much more info.


Based on your screenshots, it's definitely wrong Language Injection here. Please delete those 2 injection rules (they do not make any sense to me), it should go back to normal. If unsure: disable them first, check how it goes, if all good -- delete.

You have injected XML language inside the <div> tag ... so no more PHP as it all treated as plain text now (except the HTML tags, since they work similar to XML).

LazyOne
  • 158,824
  • 45
  • 388
  • 391