2017 © Pedro PelĂĄez
 

yii2-extension yii2-rolemanager

RBAC with access menu

image

lawiet/yii2-rolemanager

RBAC with access menu

  • Tuesday, June 12, 2018
  • by Lawiet
  • Repository
  • 1 Watchers
  • 0 Stars
  • 91 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 63 % Grown

The README.md

Yii2 Role Manager

Component to use Role Manager with Yii2, (*1)

Installation

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

Either run, (*3)

php composer.phar require lawiet/yii2-rolemanager "dev-master"

or add, (*4)

"minimum-stability": "dev",
"prefer-stable": true,
require: {
...
    "lawiet/yii2-rolemanager": "@dev"
...
}

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

Role configuration

In file web.php, (*6)

    <?php
    ....
    'user' => [
        'identityClass' => 'lawiet\rbac\models\User',
        'enableAutoLogin' => true,
        //'authTimeout' => 30,
    ],
    ....
    'modules' => [
        'rbac' => [
            'class'=>'lawiet\rbac\Module',
            'excludes'=>[
                //'modules' => ['test'], //List id Modules to RBAC exclude
                //'controllers' => ['test.default'], //List id controllers to RBAC exclude module.controller
                //'actions' => ['test.default.index'], //List id action to RBAC exclude module.controller.action
            ],
            'menu'=>[
                'icon'=>true, // boolean show icon true or false. Default: true
            ],
        ],
    ],
    ...
    ?>

In each file controllers/xxxController.php change yii\web\Controller for lawiet\rbac\web\Controller, (*7)

    <?php
    ....
    use lawiet\rbac\web\Controller;

    class xxxController extends Controller {
    ...
    ?>

And remove method behaviors or modify and add the method parent, (*8)

    <?php
    ....
    class xxxController extends Controller {
    ....
    public function behaviors()
    {
        return parent::behaviors();
    }
    ...
    ?>

Generate principal menu dynamically in your layout add, (*9)

    <?php
    ....
    use lawiet\rbac\web\Access;

    ....
    NavBar::begin([
        'brandLabel' => Yii::t('app', 'My Company'),
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
    echo Nav::widget(Access::getPrincipalMenu());
    NavBar::end();
    ...
    ?>

Run command, (*10)

php yii migrate  --migrationPath=@lawiet/rbac/migrations --interactive=0

The Versions

12/06 2018

dev-master

9999999-dev

RBAC with access menu

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jorge GonzĂĄlez

extension auth yii2 module rbac role manager rolemanager