use \Permission\Permission; $permission = new Permission(); $permission->addRole('admin'); $permission->addPermission('create_user', 'admin'); $permission->addPermission('edit_user', 'admin');
$userPermissions = $permission->getUserPermissions($userId); if ($userPermissions->hasPermission('create_user')) { // Allow user to create a new user } else { // User does not have permission to create a new user }This example shows how you can check a user's permissions based on their ID. We use the getUserPermissions() method to retrieve the user's permissions, and then check if they have the 'create_user' permission. If they do, we allow them to create a new user. If not, we deny them access. The PHP Permission library can be found on GitHub and installed via Composer.