A very simple system to handle permissions
PHP 7.0.0 or later.
You can install it via Composer by typing the following command:
composer require railken/permission
Add the trait, check here for more info.
use Railken\Permission\Traits\CanTrait;
class User
{
use CanTrait;
}
Load all permissions using setPermissions
$user->setPermissions([
'me.*',
'all.show',
]);
Note: You can use *
as a wildcard.
Now you're free to test the permission of user
$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;
Open-source software licensed under the MIT license.