PHP code example of sonphvl / authorization

1. Go to this page and download the library: Download sonphvl/authorization library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sonphvl / authorization example snippets

bash
php artisan vendor:publish --tag=authorization-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=authorization-middleware
php artisan vendor:publish --tag=authorization-config
bash
Route::prefix('admin')->group(function () {
    Route::get('/users', [UserController::class, 'index']);
});
bash
$controller->authorize('admin-user-index');
bash
Route::middleware(['authorize'])->group(function () {
    Route::get('/', function () {
        // Uses first & second middleware...
    });

    Route::get('/user/profile', function () {
        // Uses first & second middleware...
    });
});