boleiros/guardian

CakePHP 3.x 的 ACL 插件

安装: 4

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 4

分支: 0

开放问题: 0

类型:cakephp-plugin

dev-master 2017-05-20 14:03 UTC

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

使用方法

  1. 在您的用户模型中导入并使用 Guardian 特性
//User.php
<?php
namespace App\Model\Entity;

use Cake\ORM\Entity;
use Guardian\Model\Traits\Guardian;

class User extends Entity
{

    use Guardian;
    ....

  1. 通过传递权限名称调用方法:$user->hasPermission('users.index')