permissions laravel code example
Example 1: laravel file permissions
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Example 2: laravel folder permission
cd /path/to/root;
sudo chmod -R 777 ./
sudo chown -R www-data:www-data ./
sudo usermod -a -G www-data ubuntu
sudo find ./ -type f -exec chmod 644 {} \;
sudo find ./ -type d -exec chmod 755 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Example 3: laravel permission
//install laravel permission with composer installer for Laravel 6.0 or higher
composer require spatie/laravel-permission
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
Example 4: spatie/laravel-permission
// Install package
composer require spatie/laravel-permission
// config/app.php
'providers' => [
// ...
Spatie\Permission\PermissionServiceProvider::class,
];
// Publish config file
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
// Clear cache
php artisan optimize:clear
# or
php artisan config:clear
// Run migration to create tables
php artisan migrate