hscstudio/yii2-mimin
Composer 安装命令:
composer require hscstudio/yii2-mimin
包简介
Simple RBAC Manager
关键字:
README 文档
README
Simple RBAC Manager fo Yii 2.0. Minify of yii2-admin extension with awesome features
Attention
Before you install and use this extension, then make sure that your application has been using the login authentication to the database. especially for yii basic template. Because without it, this extension will produce error and useless.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist hscstudio/yii2-mimin "~1.1.5"
or add
"hscstudio/yii2-mimin": "~1.1.5"
or add this for install last change
"hscstudio/yii2-mimin": "~1.*"
to the require section of your composer.json file.
Configuration
Once the extension is installed, simply use it in your code by :
in config
'as access' => [ 'class' => '\hscstudio\mimin\components\AccessControl', 'allowActions' => [ // add wildcard allowed action here! 'site/*', 'debug/*', 'mimin/*', // only in dev mode ], ], ..., 'modules' => [ 'mimin' => [ 'class' => '\hscstudio\mimin\Module', ], ... ], 'components' => [ 'authManager' => [ 'class' => 'yii\rbac\DbManager', // only support DbManager ], ],
Because this extension use 'yii\rbac\DbManager'as authManager, so You should migrate rbac sql first:
yii migrate --migrationPath=@yii/rbac/migrations
If You use Yii 2.0.6 version or newer, so then migrate custom table for this extension
yii migrate --migrationPath=@hscstudio/mimin/migrations
But if You install Yii 2.0.5 version or older, so then migrate custom table for this extension
yii migrate --migrationPath=@hscstudio/mimin/migrations/old
Usage
This RBAC manager have three main page, they are:
Route
To get all action route from application. In here, You can on / off permission so not shown in menu role, rename alias/type of action route, so easy readable by end user.
You can then access Route through the following URL:
http://localhost/path/to/index.php?r=mimin/route
Role
To define level access of user, what he superadmin?, staff?, cashier? etc. In this menu, You can assign permission / action route (actions in application, they are create, update, delete, etc) to role.
You can then access Role through the following URL:
http://localhost/path/to/index.php?r=mimin/role
Below screenshoot of route assignment to role

User
For standard user management, create/update/delete user, and assign role to user.
You can then access User through the following URL:
http://localhost/path/to/index.php?r=mimin/user
We recommendate you for activate pretty URL.
Implementation on Widgets
Example dynamic button
It is used for checking if route right to access
if ((Mimin::checkRoute($this->context->id.'/create'))){ echo Html::a('Create Note', ['create'], ['class' => 'btn btn-success']); } // in other case maybe You want ensure same of route so You can add parameter strict true if ((Mimin::checkRoute($this->context->id.'/create',true))){
Example dynamic menu
It is is used for filtering right access menu
use hscstudio\mimin\components\Mimin; $menuItems = [ ['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ['label' => 'Contact', 'url' => ['/site/contact']], ]; if (\Yii::$app->user->isGuest){ $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else{ $menuItems[] = ['label' => 'App', 'items' => [ ['label' => 'Category', 'url' => ['/category/index']], ['label' => 'Product', 'url' => ['/product/index']], ['label' => 'Cart', 'url' => ['/cart/index']], ]]; $menuItems[] = [ 'label' => 'Logout (' . \Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post'] ]; } $menuItems = Mimin::filterMenu($menuItems); // in other case maybe You want ensure same of route so You can add parameter strict true // $menuItems = Mimin::filterMenu($menuItems,true); echo Nav::widget([ 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems, ]);
Example dynamic action column template
It is used for filtering template of Gridview Action Column
use hscstudio\mimin\components\Mimin; echo GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ..., [ 'class' => 'yii\grid\ActionColumn', 'template' => Mimin::filterActionColumn([ 'update','delete','download' ],$this->context->route), ... ] ] ]);
How to Contribute
This tools is an OpenSource project so your contribution is very welcome.
In order to get started:
- Install this in your local (read installation section)
- Clone this repository.
- Check README.md.
- Send pull requests.
Aside from contributing via pull requests you may submit issues.
Our Team
- Hafid Mukhlasin - Project Leader / Indonesian Yii developer.
We'd like to thank our contributors for improving this tools. Thank you!
Jakarta - Indonesia
Buku Panduan
Tutorial tentang dasar-dasar RBAC atau access controll di Yii 2 dan panduan yii2-mimin dibahas secara komprehensif di buku saya ini https://hscstudio.github.io/yii2-book-id
hscstudio/yii2-mimin 适用场景与选型建议
hscstudio/yii2-mimin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.42k 次下载、GitHub Stars 达 50, 最近一次更新时间为 2015 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hscstudio/yii2-mimin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hscstudio/yii2-mimin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hscstudio/yii2-mimin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
Define your own css rule-sets for the TYPO3 CMS backend.
统计信息
- 总下载量: 10.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 50
- 点击次数: 13
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-23