Skip to content

fix: improve Composer autoload discovery for discover_app_classes() f… - #20254

Open
emyassine wants to merge 1 commit into
filamentphp:4.xfrom
emyassine:4.x
Open

fix: improve Composer autoload discovery for discover_app_classes() f…#20254
emyassine wants to merge 1 commit into
filamentphp:4.xfrom
emyassine:4.x

Conversation

@emyassine

Copy link
Copy Markdown

Summary

This PR removes the assumption that Composer is installed in a fixed vendor/ directory when discovering application classes.

It now resolves the Composer vendor directory dynamically instead of assuming a fixed path, allowing compatibility with projects that use custom Composer layouts. Vendor classes are excluded using the resolved vendor path, and the autoloader is loaded from its actual location while gracefully handling missing autoloaders.

Functional changes

  • Changes have been tested and do not break existing functionality.
  • Documentation is up-to-date (checked, although this behavior does not appear to have been documented previously).

…unction

Resolve the Composer vendor directory dynamically instead of assuming a fixed vendor/ path (not always the case). Skip vendor classes using the resolved path to support custom Composer layouts.

Signed-off-by: El Moumen Yassine <165125632+emyassine@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 22, 2026 17:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates discover_app_classes() in Filament Support to avoid assuming that Composer’s autoloader lives in a fixed vendor/ directory, improving compatibility with projects that configure a custom Composer vendor directory.

Changes:

  • Dynamically resolves the Composer vendor directory (via Composer\InstalledVersions) and builds the correct autoload.php path from it.
  • Gracefully handles missing autoloaders by returning an empty result set instead of erroring.
  • Excludes vendor classes from discovery using the resolved vendor path (with realpath() normalization).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danharrin danharrin added enhancement New feature or request pending review labels Jul 22, 2026
@danharrin danharrin added this to the v4 milestone Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants