Download the PHP package slince/cakephp-permission without Composer
On this page you can find all versions of the php package slince/cakephp-permission. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download slince/cakephp-permission
More information about slince/cakephp-permission
Files in slince/cakephp-permission
Package cakephp-permission
Short Description The library provides a flexible way to add role-based access control management to CakePHP 3.x
License MIT
Informations about the package cakephp-permission
Permission Management For CakePHP 3.x
The library provides a flexible way to add role-based access control management to CakePHP 3.x
Inspired by Laravel Permission
Quick example
Installation
-
Install via composer
-
Load the plugin in
config/bootstrap.php
: -
Add the following configuration to your
app.php
- Generate the permission migration
If ok, now run the migrate command
Usage
Models
Open your User
entity, use UserTrait
like this:
Open your UsersTable
, use UserTableTrait
like this:
Using permissions
Creates the permissions with PermissionTrait::create
or PermissionTrait::findOrCreate
Using roles and permissions
Creates a role to the database with the RoleTrait::create
or RoleTrait::findOrCreate
Give the permission to the role; You must confirm that the permission exists.
Gets all permissions of the role
Checks whether the role has permission to do something:
Removes the permission
User's roles and permissions
Add the role to the user:
Gets all the roles of user
Gets all permissions of user:
Checks whether the user has permission to do something:
Removes the role of the user:
Extending
You can extends all existing Entity or Table. Do not forget to modify the default configuration in your app.php
Requirements
- CakePHP >=3.4
- PHP 5.5.9+
LICENSE
The MIT license. See MIT