Different icon for php class files

I have three types of php files in my project:

  • *.php - Procedural php files that act as landing pages
  • *.inc - Procedural php files included/required in other files
  • *.inc - Php class files.

I'd like to be able to tell in the Editor Tabs (which I have on the left, vertical) which files are the Php classes.

If necessary I'd be willing to use a different file-extension, though being able to change the icon or text color based on the folder they're in would be better.

I couldn't see any way to do either of those though, any ideas?

0
2 comments

Hi there,

That's not really possible (for icons).

In this IDE .. in order to have code to be recognized as PHP and have support from IDE; the file has to be associated with "PHP" file type (Settings/Preferences | File Types).

You cannot have that one file type to have different file icons.

On another hand -- depending on how your code is written and how you name your files and classes, PhpStorm will be showing different icons:

  • It will show "(C)" (class) icon if file has only one class and class name matches file name
  • It will use "(I)" (Interface) icon for interfaces (same conditions)
  • Similar for Traits, Exceptions
  • Files with more than one class/interface/ect in a file; or with some additional code ...; or no classes at all; or not-matching-file-name rule . it will show plain PHP file icon.

Check this comment for example: https://youtrack.jetbrains.com/issue/WI-18878#comment=27-1546559

-----

The only other thing I might suggest is custom Scopes in combination with File Colors -- if done properly it will allow to have different tab backgrounds for each scope (NOTE: scope works with file names/path names only -- not their content). This may not solve your issue in full (as it does not affect icons and does not work with file content) -- it's only partial solution that might work if files are located in folder structure in certain places.

-----

Other than that -- you will have to write your own plugin where you can dynamically decide what icon you want to show.

0

Ah, thanks Andriy, that's exactly what I want!

The (C) icon does show for my class files in some places, but not others:

  • Project tool window: yes
  • Navigation bar: yes
  • Editor tabs: no - this is the one I wanted
  • Switcher/Recent Files: no - I'd like it here too

I've made a new issue: https://youtrack.jetbrains.com/issue/WI-33979

And in the mean time the scopes idea works great too - thanks!

0

Please sign in to leave a comment.