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.
get_declared_classes() or recursive glob() scans with cached, parallelized discovery. Critical for admin dashboards, IDE plugins, or CLI tools that analyze codebases on demand.@Form to generate CRUD interfaces (e.g., for admin panels).Authorizable to auto-register middleware or ACL rules.@ListenTo to dynamically bind event handlers (e.g., for real-time analytics).ShouldBeTested).phpmd or pdepend are better suited.phpstorm-api for deeper IDE integration.AppServiceProvider or Symfony’s CompilerPass instead of runtime discovery.symfony/finder or league/container for more granular control.For Executives: *"This package lets us automate code discovery—like a GPS for our PHP codebase—so we can build features faster without manual busywork. For example:
PaymentGateway).@Configurable).For Engineers:
*"This replaces hacky glob() + class_exists() loops with a type-safe, cached, and parallelized discovery tool. Key wins:
get_declared_classes() hacks: Query classes by traits, attributes, or inheritance chains (e.g., Discover::in(app_path())->withAttribute(Cacheable::class)->get()).php artisan structure-scouts:cache) for instant results.App\Policies namespace’) or build your own cache drivers.
Use cases:ThrottleRequests to rate-limited routes).@OpenApi annotations.ShouldTest interfaces.
Tradeoff: First run is slower, but caching makes it negligible. Perfect for tools, not runtime-critical paths."*How can I help you explore Laravel packages today?