spatie/laravel-route-discovery
Automatically discover Laravel routes by scanning controllers and views instead of manually defining them. Configure discovery in your routes files and use PHP attributes to customize names, middleware, and more for each discovered route.
This package can automatically discover and register routes for a directory containing controllers.
You can enable route discovery via the routes file.
// in a routes file
use Spatie\RouteDiscovery\Discovery\Discover;
Discover::controllers()->in(app_path('Http/Controllers'));
Alternatively, you can discover routes using the config file.
First, you need to publish the config file. This will create a file at config/route-discovery.php
php artisan vendor:publish --tag="route-discovery-config"
In the discover_controllers_in_directory key of the route-discovery config file, you can specify a directory that contains controllers.
Here you can uncomment the line to register controllers in the app_path('Http/Controllers') directory. Of course you can use any directory you want.
// config/route-discovery
/*
* Routes will be registered for all controllers found in
* these directories.
*/
'discover_controllers_in_directory' => [
app_path('Http/Controllers'),
],
// ...
How can I help you explore Laravel packages today?