I've PHP project, so till now I've been using Intellij IDEA for both Java and PHP without any problem. But now, I've an old PHP project, the project uses HTML files as a PHP files. I mean files with HTML extensions contain PHP code.
However IDEA doesn't recognize them as a PHP file, but when I change extension to PHP it shows everything is fine.
So how can I force IDEA to accept HTML files as PHP files?
Is there any workaround ?
Go to File > Settings > File Types (under IDE Settings
).
Under Recognized File Types
, find PHP files (PHP)
(assuming you're using the PHPStorm plugin as I am, if not find where your *.php
file extension is registered). If you click on this, then look at Registered Patterns
, you will see all file patterns that will be recognized as PHP files. You can click the green +
on the right-hand side of the patterns pane, and it will ask for a file-name pattern to recognize as a PHP file. Enter *.html
(or something more specific if your HTML files all follow a similar naming pattern). When you hit OK, it will likely say that *.html
is already registered with HTML Files. Go ahead and reassign it, then hit OK on the Settings window. Your *.html
files will now be recognized as PHP files instead of just HTML files.
I just tested this out in 12.0.4 and it works as I described above.
Do note, however, that this seems to be an IDE-wide setting, and isn't project specific. This unfortunately means that you will have to re-register *.html
with HTML Files when opening your other, newer project with the correct file extensions. This is why I suggested a more specific pattern than *.html
if your files allow for it, or if you can change the filenames to allow for that.
The most up-to-date way of doing this in IntelliJ can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With