Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Auto Discoverer Laravel Package

spatie/laravel-auto-discoverer

Fast, cached discovery of PHP classes, interfaces, traits, and enums based on conditions. Scan directories to find structures implementing an interface, using attributes, extending classes, and more—ideal for auto-registration and production-ready performance.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Developer Productivity: Reduces manual effort in locating classes/interfaces/enums/traits, accelerating development cycles (e.g., refactoring, dependency mapping).
  • Codebase Scalability: Enables dynamic discovery of components (e.g., plugins, modules) without hardcoding paths, supporting modular architectures.
  • Build vs. Buy: Justifies buying this lightweight package over custom solutions for discovery logic, especially in PHP/Laravel ecosystems.
  • Use Cases:
    • Plugin Systems: Auto-discover custom plugins/modules (e.g., Discover::plugins()->implementing(PluginInterface::class)).
    • Testing: Generate test data by finding all classes extending a base model.
    • Documentation Tools: Extract class hierarchies for API docs or IDE plugins.
    • Migration Tools: Identify classes using deprecated methods/interfaces.

When to Consider This Package

Adopt if:

  • Your Laravel/PHP app has complex class hierarchies (e.g., plugins, event listeners, service providers) requiring frequent traversal.
  • You need dynamic discovery (e.g., auto-loading configurations, validating implementations).
  • Your team spends time on manual class_exists() checks or regex-based path searches.
  • You’re building extensible systems (e.g., CMS, SaaS platforms) where components register themselves.

Look elsewhere if:

  • Your codebase is small/flat (discovery overhead isn’t justified).
  • You need real-time file system monitoring (consider symfony/finder + custom logic).
  • You require deep AST analysis (e.g., method-level inspection; use phpstan/phpstan).
  • Your team lacks PHP/Laravel familiarity (steepness of fluent API may require onboarding).

How to Pitch It (Stakeholders)

Executives: "This package automates the tedious task of manually tracking classes/interfaces in our PHP codebase—saving dev time and reducing bugs from outdated references. For example, if we’re building a plugin system for [Product X], it’ll let us auto-detect compatible plugins without hardcoding paths, cutting onboarding time by ~30%. It’s a low-risk, high-reward tool with MIT licensing and Spatie’s track record for reliability."

Engineering: *"Spatie’s auto-discoverer replaces ad-hoc get_declared_classes() hacks with a cached, fluent API for finding classes by traits/interfaces. Key wins:

  • Performance: Built-in caching avoids repeated filesystem scans.
  • Flexibility: Chain methods like Discover::in(app_path())->classes()->implementing(Contract::class).
  • Maintainability: Works seamlessly with Laravel’s service container. Tradeoff: Minimal learning curve for PHP devs; no runtime overhead if cached properly.* Proposal: Pilot in [Module Y] to replace current manual discovery logic."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport