Permission
A very simple system to handle permissions, (*1)
Requirements
PHP 7.0.0 or later., (*2)
Composer
You can install it via Composer by typing the following command:, (*3)
composer require railken/permission
Usage
Add the trait, check here for more info., (*4)
use Railken\Permission\Traits\CanTrait;
class User
{
use CanTrait;
}
Load all permissions using setPermissions, (*5)
$user->setPermissions([
'me.*',
'all.show',
]);
Note: You can use * as a wildcard., (*6)
Now you're free to test the permission of user, (*7)
$user->can('me.anything'); // true
$user->can('foo'); // false
$user->can('all.wrong'); // false
$user->can('all.show'); // true
$user->can('all.show.wrong'); // false
Check tests to see more examples;, (*8)
License
Open-source software licensed under the MIT license., (*9)