mata / mata-rbac
MATA 的灵活用户注册和认证模块
dev-master
2015-04-13 14:30 UTC
This package is not auto-updated.
Last update: 2024-09-14 18:04:05 UTC
README
文档
安装
使用 Composer 安装
安装此扩展的首选方式是通过 composer。
运行以下命令
php composer.phar require mdmsoft/yii2-admin "~1.0"
for dev-master
php composer.phar require mdmsoft/yii2-admin "dev-master"
或添加
"mdmsoft/yii2-admin": "~1.0"
到你的 composer.json
文件中的 require 部分。
从存档安装
从这里下载最新版本 发布 然后将其解压到你的项目中。在你的应用程序配置中,为该扩展添加路径别名。
return [ ... 'aliases' => [ '@mdm/admin' => 'path/to/your/extracted', ... ] ];
使用
一旦安装了扩展,只需按照以下方式修改你的应用程序配置
return [ 'modules' => [ 'admin' => [ 'class' => 'mdm\admin\Module', ... ] ... ], ... 'components' => [ .... 'authManager' => [ 'class' => 'yii\rbac\PhpManager', // or use 'yii\rbac\DbManager' ] ], 'as access' => [ 'class' => 'mdm\admin\components\AccessControl', 'allowActions' => [ 'admin/*', // add or remove allowed actions to this list ] ], ];
详见 Yii RBAC 获取更多详情。然后你可以通过以下 URL 访问 Auth 管理器
https:///path/to/index.php?r=admin
https:///path/to/index.php?r=admin/route
https:///path/to/index.php?r=admin/permission
https:///path/to/index.php?r=admin/menu
https:///path/to/index.php?r=admin/role
https:///path/to/index.php?r=admin/assignment
要使用菜单管理器(可选)。在此处执行 yii 迁移
yii migrate --migrationPath=@mdm/admin/migrations
如果你使用数据库(类 'yii\rbac\DbManager')来保存 rbac 数据。在此处执行 yii 迁移
yii migrate --migrationPath=@yii/rbac/migrations
自定义控制器
某些控制器属性可能需要更改。要执行此操作,请通过 controllerMap
属性进行更改。
'modules' => [ 'admin' => [ ..., 'controllerMap' => [ 'assignment' => [ 'class' => 'mdm\admin\controllers\AssignmentController', 'userClassName' => 'path\to\models\User', 'idField' => 'user_id', // id field of model User ] ], ... ] ... ],
自定义布局
默认情况下,module
使用应用程序布局作为模板。要更改它,你必须设置 layout
属性。此扩展提供了三个可以使用的布局,分别是 'left-menu'、'right-menu' 和 'top-menu'。
'modules' => [ 'admin' => [ ..., 'layout' => 'left-menu', // default null. other avaliable value 'right-menu' and 'top-menu' ], ... ],
如果你使用其中之一,你也可以自定义菜单。你可以更改菜单标签或禁用它。
'modules' => [ 'admin' => [ ..., 'layout' => 'left-menu', // default null. other avaliable value 'right-menu' and 'top-menu' 'menus' => [ 'assignment' => [ 'label' => 'Grand Access' // change label ], 'route' => null, // disable menu ], ], ... ],