1. Go to this page and download the library: Download betocampoy/champs-access 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/ */
betocampoy / champs-access example snippets
use BetoCampoy\Champs\Access\AccessChecker;
use BetoCampoy\Champs\Access\ArrayPermissionProvider;
use BetoCampoy\Champs\Access\GenericUser;
use BetoCampoy\Champs\Access\GenericResource;
use BetoCampoy\Champs\Access\Permission;
$provider = new ArrayPermissionProvider([
'admin' => [
'users' => [
Permission::ACCESS => true,
Permission::CREATE => true,
Permission::UPDATE => true,
Permission::DELETE => true,
],
],
]);
$checker = new AccessChecker($provider);
$user = new GenericUser(1, 'admin');
$resource = new GenericResource('users', 'users');
$checker->can($user, $resource, Permission::UPDATE); // true
use BetoCampoy\Champs\Access\PermissionProviderInterface;
final class DatabasePermissionProvider implements PermissionProviderInterface
{
public function permissionsFor($user, $resource): array
{
return [
'acessar' => true,
'alterar' => true,
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.