:permission generation for all your declared routes with corresponding controller action

1.0.3 2022-02-21 13:57 UTC

This package is auto-updated.

Last update: 2022-09-21 22:27:32 UTC


Latest Version on Packagist Total Downloads Build Status StyleCI

This package add some artisan command to help generating permissions for your declared routes.

For the permissions management this package use Laravel-permission by Spatie


Each of your routes that you want to add permission should have an alias (name) seperated by dot(.) for exemple:

Route::get('/posts/special_action',[App\Http\Controllers\PostController::class, 'specialaction'])->name('posts.specialaction');
Route::get('/posts/another_action',[App\Http\Controllers\PostController::class, 'anotheraction'])->name('posts.anotheraction');

In this example permissions will be generated for the PostController linked to the specialaction and anotheraction

public function __construct()//#

Take a look at to see a to do list.


Via Composer

$ composer require mouhamedfd/permissions-generator

Publish configuration

php artisan vendor:publish --tag=permissions-generator.config

The default configuration exclude some keywords and some columns, it's also possible to add some middlewares

return [



Simulation mode

php artisan permission:generate

Database mode

php artisan permission:generate --action=database

Insertion to controllers

php artisan permission:generate --action=controllers

Change log

Please see the changelog for more information on what has changed recently.

Testing PHPUnit

git clone
composer install
cp vendor/spatie/laravel-permission/config/permission.php vendor/orchestra/testbench-core/laravel/config/permission.php
vendor/bin/testbench cache:clear
vendor/bin/testbench config:clear
composer exec phpunit [or vendor/bin/phpunit]


Please see for details and a todolist.



MIT. Please see the license file for more information.