PHP code example of keenops / auth-client

1. Go to this page and download the library: Download keenops/auth-client 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/ */

    

keenops / auth-client example snippets


// Require authentication
Route::middleware('auth.server')->group(function () {
    Route::get('/dashboard', DashboardController::class);
});

// Require specific permissions
Route::middleware(['auth.server', 'server.permission:manage_users'])->group(function () {
    Route::get('/admin/users', UserController::class);
});

use Illuminate\Support\Facades\Auth;

$user = Auth::guard('auth-server')->user();

// Check roles
if ($user->hasRole('admin')) {
    // ...
}

// Check permissions
if ($user->hasPermission('create_post')) {
    // ...
}
bash
php artisan vendor:publish --tag=auth-client-config