Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure "Directories" when using a Symfony project in PhpStorm

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:

enter image description here

Here is what I'm trying to avoid: results from vendor/ are shown:

enter image description here

Here is the PHP configuration:

enter image description here

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.

like image 870
A.L Avatar asked Feb 26 '16 14:02

A.L


People also ask

What is vendor folder in Symfony?

The "vendor" folder is a standard in every application / framework that uses composer to manage dependencies. In the "vendor" folder you will find all dependencies (read: libraries) that your applicatication requires. But you will also find all libraries that your libraries require.


1 Answers

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.

like image 188
Quolonel Questions Avatar answered Sep 22 '22 20:09

Quolonel Questions