Prevent PHPStorm from automatically exclude some folders
已回答
Hello everyone,
I've got an issue on all my projects with PHPStorm, when I remove my folder "vendor" (at the root of my project) and run a "composer install", all the subdirectories of "vendor" (re-created by composer) are automatically added to the "Exclude" list of directories.
So, I'm left with a huge list of folder I need to manually un-exclude one by one, in order to be able to search in it.
Here's my question: How can I tell PHPStorm to NEVER exclude a folder on its own and let me handle this ?
If that's not possible, how can I mass un-exclude folders ? I've searched for the list in config files but didn't manage to find anything.
Thanks in advance.
Regards,
F.
请先登录再写评论。
Hi there,
IDE behaves just fine -- that's the desired behaviour.
By default all composer packages (which is a 3rd party code that you should not be editing directly) will be excluded from the project and then re-added back as PHP Include paths. This allows for such code to participate in code completion / symbol resolution etc while not showing todos and other stuff from there and not performing detailed analysis if their code (it's 3rd party code as far as this project concerns).
In any case: such behaviour can be changed by disabling "Add packages as libraries" option on Composer setting page: https://www.jetbrains.com/help/phpstorm/composer-page.html
>If that's not possible, how can I mass un-exclude folders ? I've searched for the list in config files but didn't manage to find anything.
At Directories settings page: https://www.jetbrains.com/help/phpstorm/settings-directories.html
You said "So, I'm left with a huge list of folder I need to manually un-exclude one by one, in order to be able to search in it.". Why do you need search in it?. What kind of search you do?
Symbol resolution (navigate to method/class etc) works just fine with such "excluded" folders.
In any case: "Find in Path" will work -- just specify the right Scope that will also include Libraries or search in specific folder, e.g. project root (then it will also include excluded folders).
Hi Andriy,
Thanks a lot for your answer ! I'll give a try to uncheck "Add packages as libraries" then. I totally understand this is the desired behaviour and this is why I didn't talked about a bug but a problem I have specifically.
About the Directories settings, I knew it, but the problem is that in vendor we have basically the following structure: "vendor/[vendor-name]/[module-name]" and it's the module which is ignored not the vendor. And we have a lot of vendors and it's still painful to go through all. My question about this point should've been "Where does PHPStorm stores the list of excluded folders in its config files ?"
For the search I might missed something here but some times I'm pretty sure PHPStorm just don't want to search in the excluded folders :/
Regarding my needs to look into vendor, I'm working on Magento 2 projects, which is not a... very stable solution yet. We very rarely do patches, but sometimes just identifying where in the core is the problem is mandatory to fix it in our code. Plus we have quite a lot of developpers on this tech, we have many internal modules in my company. So if I encounter some bugs in these, I need to be able identify them and patch their dedicated projects then composer update etc...
To give you full info, we also recently went through a PHP 5 -> PHP 7 upgrade on some projects, which required a LOT to check vendor code, and with the PHP 5 version still living during this time, switching branches and re-doing composer commands was laborious sometimes with everything going ignored :-)
Anyway, thanks again for your answer, it works like a charm :-)
Regards,
F.
>My question about this point should've been "Where does PHPStorm stores the list of excluded folders in its config files ?"
I would not recommend going this way.
In any case: It's all in .idea subfolder where IDE keep this project settings.
>For the search I might missed something here but some times I'm pretty sure PHPStorm just don't want to search in the excluded folders :/
Maybe it was not showing you ALL matches (as in-place results is still just a preview and show TOP 100 results only -- you may see the text on right side of the search box -- when it has "XX+ matches in XX+ files" kind of text the you better hit "Open in Find Window").
Other than that either use right scope (e.g. "All Places" or "Project and Libraries") or use Directory option -- ot works fine for me in Laravel projects.
In PhpStorm 2018.2.4, unchecking "Add packages as libraries" option does not work! Packages are again automatically added to the exclude list when the project is reopened.
This is very annoying, please fix this.
@Eddie Decker
Please post screenshot of your settings, that one in particular (full settings window, not just part of it).
It happens totally randomly. Sometimes, for older projects, vendor directories are not added to the exclude list, while on new ones, it takes five or six unchecking options, removing directories from exclude list and restarts to stop it from happening.
Your settings look fine.
>Packages are again automatically added to the exclude list when the project is reopened.
That would usually be caused by "Synchronize IDE settings with composer.json" option (as such sync happens usually on project opening).
Maybe you are trying to do all those exclusion actions while project indexing is still in progress...
Another possible idea -- you were editing wrong settings (there is "File | Settings" for current project and "File | Default Settings" that affects only future new projects)...
No better ideas from my end right now, sorry.