clean-bandits / single-action-resource-controllers-for-laravel
v1.2.0
2025-02-20 09:18 UTC
Requires
- php: >=8.2
- illuminate/routing: >=11.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.58
- orchestra/testbench: ^9.1
- pestphp/pest: ^2.34
README
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.
How does it work?
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:
Installation
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, ];
Testing
composer test