spatie/php-structure-discoverer
Discover PHP classes, interfaces, traits, and enums that match conditions (e.g., implement an interface) across your project. Fast scanning with built-in caching and rich metadata—ideal for auto-registration, tooling, and framework integrations.
Discover::in()->classes()->implementing()), which is intuitive and composable. This fits well with Laravel’s expressive syntax and dependency injection patterns.DiscoveredClass, DiscoveredInterface, etc.) with inheritance chains, attributes, and file metadata. This is valuable for tooling, migrations, or dynamic feature flags.amphp/parallel for parallel scanning (optional but recommended for large codebases). No other heavy dependencies.withoutChains() if not needed.filesystem.updated). TPMs may need to integrate with spatie/laravel-medialibrary or similar.composer dump-autoload.structure-scouts:cache?phpDocumentor or Symfony ClassLoader meet needs with less overhead?laravel-zero or roave/security-advisories offer similar functionality?Discover::in(app_path(), package_path())).composer require spatie/php-structure-discoverer.php artisan vendor:publish --tag="structure-discoverer-config".Discover::in(app_path('Models'))->get()).structure_scout_directories in config/structure-discoverer.php.php artisan structure-scouts:cache.amphp/parallel compatibility if using parallel scanning.composer dump-autoload is run post-install.Discover::in()->classes()->get()).implementing(), withAttribute()).StructureScout for reusable queries.extendsChain, implementsChain) overhead.Illuminate\Foundation\Bootstrap\LoadConfiguration) for auto-cache warming.structure-scouts:clear to deploy scripts if needed.config/structure-discoverer.php. Easy to update ignored directories or cache drivers.amphp/parallel optional). No major version conflicts expected.full() mode to inspect DiscoveredStructure objects for issues.Discover::in()->withCache('key', driver)->get().Discover::in()->parallel()->get() for memory spikes in large codebases.withoutChains()) for large inheritance graphs.app_path(), not vendor/).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Cache corruption | Stale/incomplete results | Use structure-scouts:clear or fallback to non-cached discovery. |
| Filesystem permission issues | Discovery fails | Ensure PHP process has read access to scanned directories. |
| Memory exhaustion (parallel scans) | Crash or timeouts | Reduce parallel batch size or disable parallel mode. |
| Custom condition bugs | Incorrect filtering | Unit test conditions with mock DiscoveredStructure objects. |
| Laravel cache driver failure | Cached results unavailable | Fallback to FileDiscoverCacheDriver or disable caching. |
Arrayable models").How can I help you explore Laravel packages today?