clean-bandits / single-action-resource-controllers-for-laravel
Package info
github.com/CleanBandits/single-action-resource-controllers-for-laravel
pkg:composer/clean-bandits/single-action-resource-controllers-for-laravel
Requires
- php: >=8.2
- illuminate/routing: >=11.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.58
- orchestra/testbench: ^9.1
- pestphp/pest: ^2.34
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-25 14:07:27 UTC
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, /* * Take route names and route parameters from the controller name instead of the URI. * Useful when URIs are not in English: * Route::singleActionResource('gimenes-locekli', 'FamilyMembers') gets family-members.* route names * and a {familyMember} parameter. Names and parameters passed explicitly still win. */ 'names_from_controller' => false, ];
Route names from the controller
By default, route names and route parameters come from the URI, as with Route::resource(). When your URIs
are not in English, turn on names_from_controller and they follow the controller name instead:
Route::singleActionResource('gimenes-locekli', 'FamilyMembers'); // GET gimenes-locekli family-members.index FamilyMembers\IndexController // GET gimenes-locekli/{familyMember}/edit family-members.edit FamilyMembers\EditController
->names() and ->parameters() passed explicitly still win.
Testing
composer test