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?

Thanks,
Russell

8 comments

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.

1

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: http://youtrack.jetbrains.net/issue/WI-3885 ? Or is there another way?

0

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)...

0

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

0

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 ...)

0

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?

Thanks!
0

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

0

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

0

Please sign in to leave a comment.