1. Go to this page and download the library: Download dbeurive/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/ */
dbeurive / rbac example snippets
use dbeurive\Rbac\RolesHierarchy;
// Specify the hierarchy of roles using the builder
$hierarchy = new RolesHierarchy("super-admin");
$hierarchy
->addSubRole("admin")
->addSubRole("admin-bouygues")
->addSubRole("user-bouygues")
->up()
->up()
->addSubRole("admin-orange")
->addSubRole("user-orange")
->up()
->up()
->up()
->addSubRole("other-admin");
// Test a given role.
if ($hierarchy->canAccessResource("super-admin", "admin")) {
// "super-user" can access resources managed by "admin".
}