php storm css/js code completion for files not directly resovled

Is there a way to tell phpstorm the actual path of a css/js file that it cant resolve its self?

For example i have view templates stored outside the webroot, or php files with a php var in the src attribute.

I know i can use phpdoc comments to get code completion for php classes it cant resolve, eg:

*@var $bob \Bob

$bob = Singleton::returnInstance();

So is there something similar for css/js paths?

<script src="js/script.js></script>


Comment actions Permalink

Hi there,

Please provide your folder structure.

Generally speaking: if file is outside of the project root (not part of the project) then it cannot be resolved (since IDE does not know about it).

If website root is inside project but not the same as project root (e.g. "PROJECT_ROOT/httpdocs"), then marking such folder as Resource Root ("Settings | Directories" or via context menu in Project View) should help (but you have to use URLs relative to the root, e.g. "/assets/css/main.css" instead of relative to the current file "assets/css/main.css").

Comment actions Permalink

Great, my project structure is like your second suggestion, so looks like Resource Root is the way to go.

Thanks a lot


Please sign in to leave a comment.