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.
Discover::plugins()->implementing(PluginInterface::class)).Adopt if:
class_exists() checks or regex-based path searches.Look elsewhere if:
symfony/finder + custom logic).phpstan/phpstan).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:
Discover::in(app_path())->classes()->implementing(Contract::class).How can I help you explore Laravel packages today?