This package extends Laravel Router with new feature - Route::singleActionResource()
It's combination of Route::resource together
with Single Action Controllers.
If you are interested in small highly cohesive controller classes that follow standard naming convention this package is
definitely for you.
It's really simple:
- Just add new single action resource route in your routes file, e.g
Route::singleActionResource('photos');
- Create new Single Action Controllers for each
action you need, like this:
- This will automatically create these routes:
You can install the package via composer:
composer require clean-bandits/single-action-resource-controllers-for-laravel
Optionally you can publish the config file with:
php artisan vendor:publish --provider="CleanBandits\SingleActionResourceControllers\SingleActionResourceControllersProvider" --tag="config"
This is the contents of the published configuration file:
return [
/*
* Specify root namespace where your single action resource controller folder will reside
*/
'controllers_namespace' => 'App\\Http\\Controllers\\',
/*
* This class is responsible for building Resource controllers naming and location.
* By default they reside inside namespace -> controllers_namespace+resource_name+action,
* e.g. App\Http\Controllers\Photos\IndexController
* To take full control of controller namespace creation,
* you can provide your own class that implements ResourceController
*/
'resource_controller' => DefaultResourceController::class,
];
composer test