railken/permission

v1.0.1 2017-10-23 23:48 UTC

This package is auto-updated.

Last update: 2024-11-05 19:22:43 UTC


README

A very simple system to handle permissions

Requirements

PHP 7.0.0 or later.

Composer

You can install it via Composer by typing the following command:

composer require railken/permission

Usage

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;

License

Open-source software licensed under the MIT license.