How do I set a mapping between URL path and filesystem path?

I have a CSS file where the following line generates a warning from PhpStorm:

  background: url("/foo/img/image.gif");

saying "cannot resolve directory 'img'.

This is probably because in my project, the file location is foo/www/img/image.gif (in Apache I have an alias that points /foo to my foo/www directory).
How do I set up this mapping in PhpStorm, so it knows the correct location?



Hi Russell,

File | Settings | Directories and mark the parent of foo folder (or maybe even a foo folder itself, may work) as a Resource root.


Thanks Andriy, but that doesn't seem to work. The actual resource root is the directory `foo/www`, but in the URL the path is just `foo`. I can specify this mapping in the Deployment settings page, but the IDE seems to ignore that for the purpose of inspections. Maybe I need this to be fixed: ? Or is there another way?


Yeah ... I think you have found the correct ticket.

Just a thought (since I do not know the details) -- maybe in your project instead of Apache alias you can use symbolic link somehow (or change the project structure so no such aliases are used)...


I also have this issue in my application.

My project root is "F:\cakephp\"
I have a file in "F:\cakephp\app\webroot\img"
When I write this in my php file <img src="/img/myimage.jpg">
phpStorm says that "can not resolve file myimage.jpg"

One year passed since @Andriy's comment.
Is there any news about this issue?
Or should i follow this ticket

Thank you


Hi ben,

In your case it should be simple -- mark "F:\cakephp\app\webroot\" as Resource Root (either in Settings | Directories) or via context menu in Project View panel (when clicking on a folder | Mark directory as ...)


I'm having a very similar problem.

I have a .scss file which contains this rule:

.my-css-class {
    background: transparent url('/bundles/xxx/images/icon-info.gif') center center no-repeat;
    display: block;
    height: 13px;
    width: 13px;

PHPStorm is complaining that it can't resolve any of the directories referenced in the URL.

The file in question - icon-info.gif - is in my project under yyy/web/bundles/xxx/images , and I have set yyy/web as a resource root (I've also tried yyy/web/bundles), but to no avail.

Can you help?


7 Years On From Original Comment, 3 Years For The Scss. Please Help ?

Vladimir Luchansky

@14042256 Did you face the same issue? Please share more details.


I have a similar problem with WebStorm. The directory with images and other assets is not in the project structures.

I'm writing a Web Component in Angular Elements and the fixed assets are hosted by the legacy application client of my component.

Is there a way to define a mapping between physical (on hard disk) and virtual (mapped by web server) directory? Or to ignore warning for specific directory?




So, just to confirm, you have a warning for the file that is located outside the project directory?

As for the "ignore", there is a way to suppress the warning for the specific statement, just "Alt-Enter" on the warning and select the "Suppress for statement" option:


Please sign in to leave a comment.