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.
Strengths:
Reflection* classes, reducing boilerplate for type/structure discovery.app_path(), service providers).Fit for:
Misalignment:
Laravel Compatibility:
structure-scouts:cache command integrate cleanly.Non-Laravel PHP:
Key Integration Points:
booted, registered) to cache scouts on demand.ValidatesRequests").Cache Invalidation:
post-deploy hooks).Parallel Processing:
parallel(10) instead of default 50).Custom Conditions:
DiscoverCondition classes.Dependency Bloat:
amphp/parallel for parallel scanning (~1MB). Mitigate by:
require-dev for testing).Laravel Version Lock:
^ in composer.json to allow minor updates.Use Case Clarity:
ShouldQueue.")Performance Requirements:
Operational Constraints:
Maintenance:
Alternatives:
phpDocumentor/reflection-docblock) suffice?laravel/scout for search, but not discovery)?Scaling:
Laravel Ecosystem:
file, redis, or database) for scouts.NullDiscoverCacheDriver in tests to avoid filesystem I/O.Non-Laravel PHP:
FileDiscoverCacheDriver for simplicity.Discover class or use in-memory cache drivers.Complementary Tools:
| Phase | Action | Tools/Commands |
|---|---|---|
| Evaluation | Benchmark discovery speed vs. native reflection. | Discover::in(__DIR__)->get() + microtime() |
| Pilot | Implement a single use case (e.g., auto-registering console commands). | Discover::in(app_path('Console/Commands'))->classes()->get() |
| Core Integration | Publish config, set up scouts for critical paths (e.g., policies, events). | php artisan vendor:publish --tag="structure-discoverer-config" |
| Optimization | Enable parallel scanning and cache warming. | Discover::in(__DIR__)->parallel()->get() + php artisan structure-scouts:cache |
| Monitoring | Log cache hits/misses to validate performance gains. | Custom cache driver or Laravel logs. |
Laravel Versions:
PHP Versions:
amphp/parallel for PHP 7.4+ if needed.Dependencies:
illuminate/support (for Laravel cache), amphp/parallel (optional).Custom Code:
eval or create_function).app/ (configure structure_scout_directories).Discovery Scope:
app/Commands) before global discovery.ignored_files to exclude vendor/third-party code.Cache Strategy:
How can I help you explore Laravel packages today?