How to force PHPStorm to recognize a PHP file as a Javascript File.

Hello everyone,

I have a question...

I'm making a multilingual web application.
In my JS files, I have some alert functions with a text on it.
I want to change this text with PHP according to the session variable store in the session.

So rename my file functions.js by functions.php and I add header("Content-Type: text/javascript");at the beginning of the file.

It works...
Exept that PHPStorm doesn't reconize my PHP file as a JS file.
So I cannot use the Javascript auto completion (and other stuff) that helps to develop...

Is there a way to force PHPStorm to recongnize a file as a javascript even if the extension of the file is .php



Comment actions Permalink

Hi there, -- step #3

Settings | Template Data Languages -- find that file there and assign JavaScript in the right column.

Comment actions Permalink

Yes !
Thanks a lot Andriy !

I like the IDE :D


Please sign in to leave a comment.