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

Thanks

Francois

2 comments

Hi there,

http://stackoverflow.com/a/14941066/783119 -- step #3

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

0

Yes !
Thanks a lot Andriy !

I like the IDE :D

0

Please sign in to leave a comment.