I use PhpStorm to work on a Symfony project.
In the File > Settings > Project … > Directories configuration, I defined the vendor/
directory as a Resource root in order to have auto-completion and as an Excluded folder because I want to ignore vendors when performing a search in my project's code.
But my problem is that vendors are still shown in search results.
Here is my current configuration:
Here is what I'm trying to avoid: results from vendor/
are shown:
Here is the PHP configuration:
I can restrict search by selecting Scope = Custom but sometimes I forget to change this. I'm looking for some settings that I can use in my different Symfony2/3 projects.
How should I mark the vendor/
directory in order to allow PhpStorm to use it as a resource root and ignore it when performing a search?
And what is the correct configuration for the default directories structure of a Symfony2 project? Here are the default directories after a Symfony 2.8 installation with composer create-project symfony/framework-standard-edition symfony-2.8 "~2.8"
:
app/
├ config
├ cache
├ logs
└ Resources
src/
└ AppBundle/
vendor/
web/
Here is how I marked the directories at this moment:
.idea [excluded]
app/
├ config
├ cache [excluded]
├ logs [excluded]
└ Resources
src/ [source]
└ AppBundle/
└ Tests/ [test source folders]
vendor/ [excluded]
web/
Note: I installed the Symfony plugin for PhpStorm, I don't know if this change the IDE behaviour.
The vendor
folder is not a resource root. A resource root is a folder where resources such as images and scripts will be served from by the web server.
In your case the only folder that should be marked as a resource root is probably the web
folder, but ironically, is almost the only one you haven't selected as a resource root. Marking web
as the resource root means that the absolute URLs /css/foo.css
and /images/foo.jpg
could be valid resources served by the web server; you probably want to remove all other folders from resource roots.
It is correct to exclude the vendor
folder because it is not part of your first-party project code. In order for code completion to work for third-party code you must add the vendor folder as an external library. This can be done by navigating to Languages & Frameworks > PHP in the options and specifying the vendor folder as an include path.