Specifying internal include paths to get rid of the 'Path not found' warnings?

Is there a way to specify internal include paths? Some of the projects I work on have a lot of includes/requires which are not relative to the current directory. For these, the IDE gives me "Path '...' not found" warnings. If I add the specific include paths to Settings > PHP > Include Path then the warnings go away but then all those include files start showing up under the External Libraries section in the Project sidebar, which I'd prefer not to happen. In Settings > Directories I have the include paths marked as Sources but that doesn't seem to make those warnings go away.

Using PhpStorm 2023.2 Build #PS-232.8660.205 on Windows 10.

0

You may want to mark these directories as Resource root(s), this should help:

https://www.jetbrains.com/help/phpstorm/settings-directories.html

0

I had tried that before and it didn't help but I just tried again. I now have the include paths marked as both Source Folders and Resource Root but I still get that "Path '...' not found" warning.

0

Thank you for your response.
I also tried to play around with Resource Roots + includes and surprisingly, discovered that it does not work. To be honest, I was pretty confident that include/require resolve relies on Resource Roots configuration but apparently, it does not (whereas, for instance, HTML <a href> works fine there).

From remaining available options, it is possible to specify $_SERVER["DOCUMENT_ROOT"] via the "Settings/Preferences | PHP > Analysis > Include analysis" option -- that might be a workaround for you if you use $_SERVER['DOCUMENT_ROOT'] expression in includes.

0

Thanks for trying to help. These projects don't use $_SERVER['DOCUMENT_ROOT'] in includes, they're written like:

include "includes/public/file1.php"
include "public/file2.php"
include "file3.php"
0

I quickly discussed it with my colleagues and they confirmed that I was wrong -- sadly, Resource Roots have nothing to do with include/require statements. So, the only available way for now is to use Include Path, sorry.

0

请先登录再写评论。