PHP code example of equipe-web / laravel-keycloak

1. Go to this page and download the library: Download equipe-web/laravel-keycloak 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/ */

    

equipe-web / laravel-keycloak example snippets


php artisan config:cache

php artisan config:cache

php artisan clear-compiled && composer dumpautoload && php artisan optimize


...
use Secorphp;

class MeuController extends Controller {

    public function index() {
        // verifica acesso do usuário que está logado ao recurso
        if(Gate::allows('usuario_incluir') {
            // tem acesso ao recurso 
        }
    }
}

<h1>Pode acessar video?</h1>
@can("video_acessar")
<strong>Pode sim!</strong>
@else
<strong>ACESSO NEGADO!!</strong>
@end_can

<h1>Pode incluir materia?</h1>
@can("materia_incluir)
<strong>Claro que pode!</strong>
@else
<strong>ACESSO NEGADO!!</strong>
@end_can