PHP code example of jumbodroid / phprbac

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

    

jumbodroid / phprbac example snippets


$role_id = Rbac::roles()->add($title, $description);  
$role_id = Rbac::roles()->add($title, $description, $parent_id);  

$role = Rbac::roles()->getTitle($role_id);

$role_permissions = Rbac::roles()->permissions($role_id, true);  
  
Rbac::roles()->unassignPermissions($role_id);  
  
Rbac::roles()->assign($role_id, $perm_id);  
  
$ok = Rbac::roles()->remove($role_id, true);  
  
Rbac::roles()->remove($role->ID, true);  
  
$perm_id = Rbac::permissions()->add($perm_title, $perm_desc, 1);  
  
$perm_id = Rbac::permissions()->returnId($perm_title);  
  
Rbac::permissions()->unassignRoles($perm_id);  
  
Rbac::permissions()->remove($perm_id, true);  
  
Rbac::roles()->unassignUsers($role_id);  
  
$assigned = Rbac::users()->hasRole($role['ID'], $user->id);  
  
$assigned = Rbac::users()->allRoles($user_id);  
  
Rbac::users()->assign($role_id, $user_id);  
  
Rbac::users()->unassign($role_id, $user_id);