boleiros / guardian
CakePHP 3.x 的 ACL 插件
dev-master
2017-05-20 14:03 UTC
Requires
- php: >=5.5.9
- cakephp/cakephp: >=3.3.2 <4.0.0
Requires (Dev)
- cakephp/migrations: ^1.6
- phpunit/phpunit: *
This package is auto-updated.
Last update: 2024-09-29 04:53:47 UTC
README
安装
您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。
安装 composer 包的推荐方法是
composer require boleiros/guardian
启用插件
// config/bootstrap.php Plugin::load('Guardian', ['bootstrap' => true, 'routes' => true]);
或者,在您的终端中
bin/cake plugin load -b -r Gardian
运行迁移
bin/cake migrations migrate --plugin Guardian
使用方法
- 在您的用户模型中导入并使用 Guardian 特性
//User.php
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
use Guardian\Model\Traits\Guardian;
class User extends Entity
{
use Guardian;
....
- 通过传递权限名称调用方法:
$user->hasPermission('users.index')