8

I'm pretty new to PHPStorm, but I've ran into this problem where PHPStorm can't resolve the path which starts at the root of my project folder.

Like this:

Path not found

PHPStorm can resolve the path when I put

dirname(__dir__) 

in front of the name, but then I can't test my website using the run button.

When I use relative paths with ../.. PHPStorm recognizes the path as well, but again it doesn't work when testing the site, I also would rather not use relative paths.

PHPStorm is able to resolve the path from test.php which is in my root folder, but I'd like it to be able to resolve it from anywhere in my project.

Any help?

Ruben
  • 441
  • 5
  • 14
  • 1
    This was the solution: http://stackoverflow.com/questions/14175485/phpstorm-and-module-references – Ruben May 23 '15 at 14:40

2 Answers2

3
  1. Go to File... -> Project Structure.
  2. Choose Modules tab.
  3. Mark 'Model' folder as 'Sources'.
Mateusz Soltysik
  • 815
  • 9
  • 16
  • I've looked for a while but I can't find Project Structure, [using the shortcut to get there](https://www.jetbrains.com/idea/help/configuring-project-structure.html) ctrl shift alt s also doesn't do anything – Ruben May 23 '15 at 13:04
  • 1
    In PHPStorm you should go to Preferences -> Directories. – Mateusz Soltysik May 23 '15 at 13:28
  • 6
    Ok, I marked it as a source folder, it's icon turned blue, but it still doesn't work – Ruben May 23 '15 at 14:15
2

Looks like your server know include path for your project folder, so relative paths like Model/Exposition.php work well. You can check include paths with get_include_path() function.

PHPStorm has its own list of include paths for project, which you can check and modify:

  1. Open settings: File > Settings (or Ctrl+Alt+S)
  2. In settings go to Language & Frameworks > PHP, and look at Include Path tab.
  3. Of course you can add new record with full path to the root folder of your project
    (which in your case will be like C:\Users\Ruben\Documents\Multec...\Server).

So finally PHPStorm will know where to find these files.

isherwood
  • 58,414
  • 16
  • 114
  • 157
Wixty
  • 25
  • 5