wsdslm / yii2-rbac
RBAC manager for Yii framework
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0
- yiisoft/yii2-bootstrap: ~2.0
This package is not auto-updated.
Last update: 2025-01-24 20:00:21 UTC
README
- WEB UI Manager
- Route Access Filter
Todo
- I18n
Install
via Composer
composer require wsdslm/yii2-rbac
Config
# config/web.php
'components' => [
'authManager' => [
'class' => yii\rbac\DbManager::className(),
]
],
'modules' => [
'rbac' => [
'class' => ws\rbac\Module::className(),
]
],
database migration
yii migrate --migrationPath=@yii/rbac/migrations
Usage
use Route Access Filter
-
add
ws\rbac\components\RouteAccessFilter
forapp\controllers\SiteController
use ws\rbac\components\RouteAccessFilter; public function behaviors() { return [ 'rbac' => [ 'class' => RouteAccessFilter::className(), 'only' => ['t'], ], ]; } public function actionT() { return __METHOD__; }
-
Create Route access Permission at
http://localhost:8080/rbac/permission/create
- Permission Name
basic.site.t
(module_id.controller_id.action_id
)
- Permission Name
-
Create Role at
http://localhost:8080/rbac/role/create
- Role Name
admin
- Role Name
-
Manager Role at
http://localhost:8080/rbac/role/index
- Click icon cog
- Add Child
basic.site.t
-
Assign Role for User at
http://localhost:8080/rbac/assign