Installing Spatie's Laravel Permission

After reviewing a number of different packages in the area of Access Control, I have found Spatie's Laravel-Permission to be the best in class. It the best maintained and there is a good body of documentation and help out there to go along with it.

Installation of Laravel-permission is relatively straightforward. From your CLI enter the following command

php composer.phar require spatie/laravel-permission 

This will install the most up to date version of laravel-permission along with it's dependencies. Next you need to ensure the class is registered along with all the other Service Providers. Open the file app\config\app.php - at the bottom of the long list of providers add the following line (just the bit in bold)

'providers' => [
    Spatie\Permission\PermissionServiceProvider::class,
];

Now that you have added the class you can publish the package. This will copy the permission.php file from the vendor\spatie... folder to the config folder and it will copy the necessary migration file to create the database tables in which the permissions will be stored to the app\databases folder.

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"

Before we can run the migration we need to modify the

Leave a Reply