Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm can't resolve absolute include paths

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?

like image 776
Ruben Avatar asked May 23 '15 12:05

Ruben


2 Answers

  1. Go to File... -> Project Structure.
  2. Choose Modules tab.
  3. Mark 'Model' folder as 'Sources'.
like image 130
Mateusz Soltysik Avatar answered Nov 14 '22 14:11

Mateusz Soltysik


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.

like image 39
Wixty Avatar answered Nov 14 '22 14:11

Wixty