Set web root directory?

I have my directory structure like this

Project -
     classes
          theme
               products
                    -main.php
     templates
          products
               -main.tpl
     web
          index.php
          js
               main.js
          css
                main.css

The problem is, in my template file I am including main.css and main.js, (<script src="js/main.js"></script>) but phpstorm says that can't resolve directory

How Can I tell phpstorm that "web" is my base directory
I tried adding it as content root, but won't let me add it.
I also tried it is an include path, but won't add it as that either.

3 comments
Comment actions Permalink

Hi there,

"Settings | Directories" (or via context menu on that folder in Project View) and mark it as Resource Root

Also ... you may consider writing URLs/links to resources relative to the website root (<script src="/js/main.js"> -- notice the leading slash) and not to the current page (<script src="js/main.js">). Of course -- it is not a solution for 100% of situations -- there always can be situations where you would like to do opposite to my suggestion.

0
Comment actions Permalink

ok thank you.
I can't do website root because I develop on my local box and have many different projects on the web root. So all the projects are in subfolders., where as on the production server it is not.

0
Comment actions Permalink

You can setup individual sites on your local development server -- domain names can easily be faken via hosts file .. the rest is just your web server (Apache etc) server configuration (Virtual host).

If you have time and desire -- investigate and do it -- you will have environment 1 more step close to the production one.

0

Please sign in to leave a comment.