Add vendor directory to find scope
I've defined some custom scopes to use in "Find in Files". When I add Composer's vendor directory with either of the Include buttons, I only get the bin subdirectory and the autoload.php file, but none of the actual libraries. They don't even show in the bottom pane:
Is this how it's meant to behave? Is there a way to be able to search in libraries when using scopes?
Please sign in to leave a comment.
Hi there,
Composer packages (folders) from vendor folder are automatically marked as Excluded (controlled by "Settings/Preferences | PHP | Composer | Add packages as libraries" option) and then re-added back via "Include Paths" mechanic. You can see all Excluded folders at "Settings/Preferences | Directories".
This way it allows to exclude 3rd party code so it's not treated as your own (so it does not warn about TODOs/code style/unknown class/other inspection) but at the same time still allows to index them and be available in a code completion.
You cannot reference Excluded folders when making a new custom Scope.
If you want to use Find in Files to perform search in such vendor folders, please use "Scope" option and select predefined "Project and Libraries" entry:
or use "Directory" option and the actual path to the vendor folder (will search only there):
The problem is that there're several directories that I need to include or exclude depending on what I'm searching and I thought scopes would ease that, but they're not the right tool. Thank you very much!
Hi there,
Try this: select all desired folders in the Project View panel and then invoke Find in File using keyboard shortcut (not using the main menu). This way it should use special "Selected Files" scope that I expect to work in a similar way to how specifying an exact Directory works (2nd screenshot from the prev message).
I have not tested this with such excluded vendor folders... so it's just a guess / idea worth checking.
I think I'm following your instructions correctly but it defaults to "Directory" with the first directory selected. I can switch manually to "Scope/ Selected files and & directories" but it's pretty much ignoring my selection.
No worries, at least I'm more aware of how scope search works.
Yes. I though it would select the different/right scope automatically...
Just tried -- works for me. But you have to manually select the "Scope" and then "Selected directories" there.
What I did: