Skip to content

PHP: "vendor" folder should not be ignored by default #731

@pscheit

Description

@pscheit

Current Behavior

In intelephense.py, vendor directories are hardcoded to be ignored:

def is_ignored_dirname(self, dirname: str) -> bool:
    # For PHP projects, we should ignore:
    # - vendor: third-party dependencies managed by Composer
    # - node_modules: if the project has JavaScript components
    # - cache: commonly used for caching
    return super().is_ignored_dirname(dirname) or dirname in ["node_modules", "vendor", "cache"]

The Problem

This creates a contradiction with Serena's core value proposition:

Serena's instructions say: "Don't read entire files - use symbolic tools like find_symbol to explore code efficiently"

But in practice: When working with third-party libraries, I'm forced to read entire vendor files because find_symbol doesn't work on them.

Concrete example:

  • I'm using brick/date-time and need to understand how ZonedDateTime::parse() works
  • find_symbol with depth: 1 returns empty for vendor classes
  • I have to fall back to reading the entire ZonedDateTime.php file (700+ lines)
  • This defeats Serena's purpose of efficient code exploration

Why This Matters for PHP Projects

  1. Third-party library exploration is crucial - Understanding external APIs is often MORE important than understanding your own code (which you wrote)

  2. Current workarounds don't work:

    • Setting ignore_all_files_in_gitignore: false in .serena/project.yml has no effect
    • The hardcoded exclusion overrides configuration
  3. The LLM gets stuck: Claude Code receives instructions to "use symbolic tools, don't read files" but then can't use those tools on vendor code, creating confusion

Proposed Solution

Make this configurable via ls_specific_settings in .serena/project.yml:

ls_specific_settings:
  php:
    indexVendorDirectory: true  # default: false

Or alternatively as a project-level setting:

index_vendor_directories: true  # default: false

Performance Tradeoff

Yes, indexing would be slower with vendor included. However:

  • PHP developers are accustomed to slow indexing (PHPStorm: ~10 minutes)
  • This should be opt-in for teams that need it
  • The performance cost is worth it for proper third-party API exploration
  • Indexing happens once; exploration happens continuously

Testing Notes

I've locally patched line 39 to remove "vendor" from the exclusion list and can confirm:

  • Vendor indexing works correctly
  • find_symbol successfully returns methods from vendor classes
  • No issues with Intelephense handling vendor files

Would be happy to test any proposed implementation!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions