PHP code example of wg-hyve / keycloak-laravel-guard
1. Go to this page and download the library: Download wg-hyve/keycloak-laravel-guard 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/ */
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class DeleteRequest extends FormRequest
{
public function authorize(): bool
{
return Auth::hasScope('can-delete');
}
public function rules(): array
{
return [];
}
}
namespace App\Your\Service
use Illuminate\Support\Facades\Auth;
use KeycloakGuard\Models\User;
class AcmeService
{
public static function getUser(): ?User
{
return Auth::user();
}
}