How to prevent indexing the vendor folder

Hi,

I'm working on a PrestaShop project and I want to prevent indexing the vendor folder

The first thing that I tried was to exclude the vendor folder

But it was still being indexed

I searched the settings related to PHP and Composer but with no luck

I also checked similar threads (about node_modules) but didn't get a hint on how to solve this

Please advise

Thank you

 

 

PhpStorm 2019.1.2
Build #PS-191.7141.52, built on May 8, 2019
Licensed to ----
Subscription is active until November 27, 2019
JRE: 1.8.0_202-release-1483-b49 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-50-generic

15 comments
Comment actions Permalink

Hi there,

Please check "PHP | Include Paths". Libraries added this way will still be indexed even if excluded via "Directories".

P.S. By default all stuff from composer will be added as Include Paths entries (External Libraries). This behaviour can be disabled so you can have full control.

P.P.S. Please note that if you completely exclude your vendor content then you will have NO code completion for classes & functions from those folders.

5
Comment actions Permalink

Thank you for the valuable information

Best regards

0
Comment actions Permalink

Woah! Andriy, thank you! This has been driving me bonkers for years! You have no idea how many times I have tried to exclude vendor and just really didn't understand why it was still indexed. Now this all makes sense and realize I don't want it excluded. 

UX: I think Intellij should not let a user mark a directory as excluded if it is an include path. The context menu should say something like "exclusion disabled because it is an include path" or something to indicate that the exclusion is non-active. 

Until then, so happy to have this sanity back! Thanks


https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003654040/comments/360000498699

0
Comment actions Permalink

Andriyn you said:

"P.S. By default all stuff from composer will be added as Include Paths entries (External Libraries). This behaviour can be disabled so you can have full control."

How?

0
Comment actions Permalink

@Tprotopgr

Settings/Preferebces | Languages & Frameworks | PHP | Composer | Add packages as libraries

1
Comment actions Permalink

@Tprotopgr

And?..

 

P.S. Unticking that option does not do anything. I mean: it will NOT undo the changes that IDE does when it's enabled.

Disabling that option simply tells IDE to not to add newly detected composer-included packages as libraries (which marks folder as Excluded and then adds it back as PHP Include Path entry).

You have to manually remove any unwanted entries from the PHP Include Paths.

0
Comment actions Permalink

Since some days I'm really f***ed from either that feature or I just don't know what else: I removed all excludes and includes; invalidated caches several times; removed .idea folder in the project etc. still the same - some vendor packages are not indexed at all; some classes map to namespaces... I have the feeling indexing is broken in 2021.1

0
Comment actions Permalink

@Thflori

You better have this as a new thread as it does not seem related to the topic of this post.

I suggest you do that + disable all custom (not bundled by default) plugins, do the Invalidate caches (with top 2 options checked there), and restart the IDE. If still the same -- need to see logs, your project setup. Right now it could be some (outdated?) plugin... (a guess based on past observations on the threads/tickets here).

For me Carbon get recognized just fine in a typical Laravel project (be it fresh project or 2 years old one).

0
Comment actions Permalink

Just to clarify, I want the vendor folder to not come up in Find in Files, but I do need it to be traceable when I'm trying to trace which classes a function is coming from.

So I'm thinking I need to right-click the vendor folder in the Project panel, select Mark Directory As Excluded. Is that it? Or is that wrong?

0
Comment actions Permalink

Find in Files doesn't include the results from libraries if "In project" scope is selected. Libraries are the folders that are marked as excluded + are included in a project via:

- Settings (Preferences on macOS) | PHP > Include Path

- Settings (Preferences on macOS) |  | Languages & Frameworks | JavaScript | Libraries

If you're invoking Find in Files directly on a project root (as a folder) - then Find in Path would search within libraries also.

0
Comment actions Permalink

I'm only concerned about PHP vendor right now, but the vendor folder (all PHP-based libraries) are in Include Path:

What would be ideal is if Find in Files would exclude `vendor` unless I start from `vendor`. I'm not sure if manually starting (right-clicking) from Project Root folder would be useful to include vendor... but, I think I wouldn't need that, and results from vendor would more than likely just get in the way.

When I open Find in Files from a keyboard shortcut from the context of any panel (like an open file tab or the Project panel), and I click Scope, the default selected is Project Files... is that what you mean by Project Root (as a folder)?

Anyway, I can't tell if my Include Path listings are wrong (I imagine having only and all vendor there is the default behavior, so I think that shouldn't just be deleted), and I can't tell if PHPStorm is smart enough to understand or do what I want:

Exclude vendor from Find in Files search unless I specifically start from that folder/scope, and I think preferably also exclude it when searching from the top-level "folder"... typically vendor includes a zillion times more files and potential text search results than our files outside of it, and I don't want them junking up the search when I need to find files outside of it.

0
Comment actions Permalink

Thanks for the clarification. That would require a redesign of how "Find in Files" works for the entire IntelliJ platform. You can submit this proposal to our tracker at https://youtrack.jetbrains.com/newIssue for a corresponding team to review. 

I personally like how this works right now and don't think it requires any changes.

0
Comment actions Permalink

I think maybe you're not understanding what I'm asking, because I remember it working basically the way I described, but now I'm getting vendor results when searching outside and above that folder, and I'm not seeing why.

I hope you can understand why vendor results gunking up the search outside of the folder would be problematic when we're not supposed to be editing vendor files, and would only be useful when intentionally trying to target those files for search review.

I may have better ideals for search beyond that, but those are just personal wishes, and I hope and don't think that would require a redesign, and I don't think it would, because they're just sensible behaviors.

I do remember it working like this:

  1. Right-clicking a folder above vendor, doing a Find in Files, getting results from files recursively not in the vendor folder.
  2. Right-clicking vendor and doing a search, getting file results only from that folder recursively.

That seems sensible to me. I don't remember exactly what configuration I used to get Find in Files to work that way. I just had to reset the repo so the .idea folder is gone, and I'm not sure exactly how I should have the folders marked or what config I need to set to get search to behave the way it did.

I'm updating to version 2022.2.3 right now, so hopefully I can make it behave the way it used to.

 

0
Comment actions Permalink

Sorry, can't confirm what you're describing. Checked that on PhpStorm 2019.2: https://i.gyazo.com/a9d490c3eb25cbad2feabc0436d932f2.mp4

Probably the video is too small, but invoking Find in Path on a root project does return the results from vendor folder

0

Please sign in to leave a comment.