fix: improve Composer autoload discovery for discover_app_classes() f… - #20254
Open
emyassine wants to merge 1 commit into
Open
fix: improve Composer autoload discovery for discover_app_classes() f…#20254emyassine wants to merge 1 commit into
emyassine wants to merge 1 commit into
Conversation
…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>
Contributor
There was a problem hiding this comment.
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 correctautoload.phppath 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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