PHP code example of waltersilvacruz / secorphp

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

    

waltersilvacruz / secorphp example snippets


php artisan config:cache

php artisan vendor:publish --tag="secorphp"

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(Secorphp::allow('USUARIO') {
            // tem acesso ao recurso "USUARIO"...
        }

        // verifica acesso do usuário que está logado à uma ação
        if(Secorphp::allow('USUARIO', 'PODE_EDITAR') {
            // tem acesso à ação "EDITAR" no recurso "USUARIO" ...
        }
    }
}


...
use Secorphp;

class MeuController extends Controller {

    public function index() {
        // ou utilize o método user()
        if(Secorphp::user('mary')->allow('USUARIO') {
            // Mary tem acesso ao recurso "USUARIO"...
        }
    }
}