PHP code example of rampage-php / rbac
1. Go to this page and download the library: Download rampage-php/rbac 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/ */
rampage-php / rbac example snippets
// let rbac instanciate standard roles
$rbac = new rampage\rbac\Rbac();
$rbac->addRole('foo');
$rbac->addRole('bar', ['foo']);
$rbac->getRole('foo')->allow('permission');
// instanciate your own roles (they need to implement rampage\rbac\RoleInterface)
$role = new Role('baz')
$role->addChild('bar'); // will utilize $rbac->getRole('bar') if present.
$rbac->addRole($role);