2017 © Pedro Peláez
 

yii2-extension yii2-mimin

Simple RBAC Manager

image

hscstudio/yii2-mimin

Simple RBAC Manager

  • Friday, November 24, 2017
  • by hscstudio
  • Repository
  • 8 Watchers
  • 39 Stars
  • 1,879 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 28 Forks
  • 2 Open issues
  • 11 Versions
  • 9 % Grown

The README.md

Yii2 Mimin

Simple RBAC Manager fo Yii 2.0. Minify of yii2-admin extension with awesome features, (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

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., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist hscstudio/yii2-mimin "~1.1.5"

or add, (*6)

"hscstudio/yii2-mimin": "~1.1.5"

or add this for install last change, (*7)

"hscstudio/yii2-mimin": "~1.*"

to the require section of your composer.json file., (*8)

Configuration

Once the extension is installed, simply use it in your code by :, (*9)

in config, (*10)

'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:, (*11)

yii migrate --migrationPath=@yii/rbac/migrations, (*12)

If You use Yii 2.0.6 version or newer, so then migrate custom table for this extension, (*13)

yii migrate --migrationPath=@hscstudio/mimin/migrations, (*14)

But if You install Yii 2.0.5 version or older, so then migrate custom table for this extension, (*15)

yii migrate --migrationPath=@hscstudio/mimin/migrations/old, (*16)

Usage

This RBAC manager have three main page, they are:, (*17)

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:, (*18)

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:, (*19)

http://localhost/path/to/index.php?r=mimin/role

Below screenshoot of route assignment to role Screenshoot Role, (*20)

User

For standard user management, create/update/delete user, and assign role to user. You can then access User through the following URL:, (*21)

http://localhost/path/to/index.php?r=mimin/user

We recommendate you for activate pretty URL., (*22)

Implementation on Widgets

Example dynamic button

It is used for checking if route right to access, (*23)

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, (*24)

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, (*25)

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., (*26)

In order to get started:, (*27)

  • 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., (*28)

Our Team

We'd like to thank our contributors for improving this tools. Thank you!, (*29)

Jakarta - Indonesia, (*30)

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, (*31)

The Versions

24/11 2017

dev-master

9999999-dev

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

24/11 2016

v1.1.4

1.1.4.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

06/09 2016

v1.1.3

1.1.3.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

21/06 2016

v1.1.2

1.1.2.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

07/02 2016

v1.1.1

1.1.1.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

07/02 2016

v1.1

1.1.0.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

07/02 2016

v1.0.3

1.0.3.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

29/01 2016

v1.0.2

1.0.2.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

10/11 2015

v1.0.1

1.0.1.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

10/11 2015

v1.0.0

1.0.0.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2

25/10 2015

v1.0

1.0.0.0

Simple RBAC Manager

  Sources   Download

MIT

The Requires

 

extension yii2