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 structures in your codebase. Find classes, interfaces, traits, and enums by conditions like “implements interface” or “uses trait,” and get rich metadata. Ideal for automation, registration, and scanning in production.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Dynamic Code Discovery for Plugin/Extension Systems: Enables rapid development of extensible architectures (e.g., custom validation rules, middleware, or event listeners) where components must auto-discover classes implementing specific interfaces/traits. Reduces boilerplate for registration logic.
  • Refactoring & Migration Tools: Powers tools to identify classes needing updates (e.g., deprecated methods, interface changes) by scanning inheritance/implementation chains. Example: "Find all classes extending OldModel to migrate to NewModel."
  • Build vs. Buy for Custom Discovery: Avoids reinventing wheel for complex class-scanning needs (e.g., "Find all services tagged with @Injectable"). Lowers dev time for internal tools.
  • Performance Optimization: Built-in caching (via StructureScout) accelerates repeated scans in production (e.g., warm-up during deployments). Critical for CLI tools or scheduled jobs.
  • Metadata-Driven Development: Extracts rich metadata (e.g., isAbstract, attributes) to enable smarter IDE plugins, documentation generators, or testing frameworks.
  • Multi-Tenancy/Modular Apps: Isolates discovery scopes per module (e.g., Discover::in(app_path('Modules/{tenant}'))) to avoid global scans.

When to Consider This Package

  • Avoid if:
    • Your use case is simple (e.g., "list all classes in a single directory"). Use PHP’s glob() or get_declared_classes() instead.
    • You need real-time discovery (no caching). The package’s caching layer adds overhead for dynamic environments.
    • Your project is non-PHP/Laravel. The Laravel-specific cache drivers and Artisan commands limit flexibility.
    • You require fine-grained file-level control (e.g., excluding specific files dynamically). The ignored_files config is static.
  • Look elsewhere if:
    • You need cross-language discovery (e.g., TypeScript/Java). Use language-specific tools (e.g., ts-morph).
    • Your codebase is extremely large (>100K files). Parallel scanning may still be slow; consider incremental scanning or database-backed solutions.
    • You require AST parsing (e.g., analyzing method bodies). Pair with php-parser or nikic/php-parser.

How to Pitch It (Stakeholders)

For Executives: *"This package lets us automate tedious code discovery tasks—like finding all custom payment processors or deprecated APIs—without writing custom scripts. It’s like Google Search for your codebase, but for developers. For example, we could:

  • Cut refactoring time by 30% by auto-identifying classes needing updates.
  • Accelerate plugin development by auto-registering components that implement our interfaces.
  • Reduce tech debt by scanning for unused classes or outdated implementations. It’s lightweight, open-source (MIT), and integrates seamlessly with Laravel—no new infrastructure needed."*

For Engineers: *"This is a Swiss Army knife for class discovery in PHP/Laravel. Key perks:

  • Fluent API: Chain conditions like Discover::in(app_path())->classes()->implementing(Serializable::class)->get().
  • Performance: Built-in caching (via StructureScout) makes repeated scans instant in production.
  • Flexibility: Filter by traits, attributes, inheritance chains, or custom closures. Example: Find all classes using @Cacheable in app/Commands.
  • Parallel Scanning: Speed up large codebases with ->parallel() (requires amphp/parallel).
  • Laravel Native: Works with Artisan commands (php artisan structure-scouts:cache) and config publishing. Use cases:
  • Build a dynamic middleware registry by scanning for classes tagged with @Middleware.
  • Create a deprecation scanner to find classes extending OldService.
  • Power a plugin system where extensions auto-register by implementing PluginInterface. Trade-off: Adds ~100KB to your vendor dir. Worth it for complex discovery needs."*
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony