zelenin/yii2-rbac-module

此软件包已被废弃,不再维护。未建议替代软件包。

从RBAC数据存储文件rbac.php生成到数据库的分配的Yii2 RBAC模块

安装次数: 1,568

依赖关系: 0

建议者: 0

安全: 0

星标: 23

关注者: 9

分支: 10

公开问题: 0

类型:yii2-extension

0.3.0 2015-03-02 00:00 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:35:47 UTC


README

从RBAC数据存储文件生成到数据库的分配的Yii2 RBAC模块。还提供“经典”PhpManager。

安装

Composer

通过 Composer 安装此扩展是首选方式。

运行以下命令:

php composer.phar require zelenin/yii2-rbac-module "dev-master"

或者将以下内容添加到你的 composer.json 文件的 require 部分:

"zelenin/yii2-rbac-module": "dev-master"

使用方法

DbManager

在配置中配置 AuthManager 组件

'components' => [
    'authManager' => [
        'class' => \Zelenin\yii\modules\Rbac\components\DbManager::className(),
        'itemFile' => '@common/config/rbac/items.php',
        'assignmentFile' => '@common/config/rbac/assignments.php',
        'ruleFile' => '@common/config/rbac/rules.php',
        'defaultRole' => 'user',
		'roleParam' => 'role' // User model attribute
	]
]

运行以下命令:

php yii migrate --migrationPath=@yii/rbac/migrations/

或者使用 @yii/rbac/migrations/ 目录中的sql文件

从php存储文件生成分配的命令:

php yii rbac/generate

有关存储文件的示例,请参阅 example 目录

PhpManager

在配置中配置 AuthManager 组件

'components' => [
    'authManager' => [
        'class' => \Zelenin\yii\modules\Rbac\components\PhpManager::className(),
        'itemFile' => '@common/config/rbac/items.php',
        'assignmentFile' => '@common/config/rbac/assignments.php',
        'ruleFile' => '@common/config/rbac/rules.php',
        'defaultRole' => 'user',
		'roleParam' => 'role', // User model attribute
	]
]

信息

请参阅 Yii2授权指南

作者

Aleksandr Zelenin,电子邮件: aleksandr@zelenin.me