zelenin / yii2-rbac-module
此软件包已被废弃,不再维护。未建议替代软件包。
从RBAC数据存储文件rbac.php生成到数据库的分配的Yii2 RBAC模块
0.3.0
2015-03-02 00:00 UTC
Requires
- yiisoft/yii2: ~2
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授权指南