2017 © Pedro Peláez
 

yii2-extension yii2-simple-rbac

Simple RBAC module for Yii 2 framework

image

juliardi/yii2-simple-rbac

Simple RBAC module for Yii 2 framework

  • Tuesday, August 1, 2017
  • by juliardi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Yii2 Simple RBAC Status Software License

Simple RBAC module for Yii 2 Framework, (*1)

Caution : This package is still in development stage. Please do not use it for now., (*2)

Installation

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

Either run, (*4)

php composer.phar require --prefer-dist juliardi/yii2-simple-rbac "*"

or add, (*5)

"juliardi/yii2-simple-rbac": "*"

to the require section of your composer.json file and then run, (*6)

php composer.phar update

Setup

Once the extension is installed, you must first set it up by :, (*7)

  1. Register yii2-simple-rbac as a module in config\web.php. Add this code before return $config; statement :, (*8)

    $config['bootstrap'][] = 'simplerbac';
        $config['modules']['simplerbac'] = [
            'class' => 'juliardi\simplerbac\Module',
            'db' => 'db', //you can change this in case you are using different database for access control
        ];
    
  2. Run migrations, (*9)

    php yii migrate/up --migrationPath=@juliardi/simplerbac/migrations
    

    or in case you are using different database (we assume here as db2):, (*10)

    php yii migrate/up --migrationPath=@juliardi/simplerbac/migrations --db=db2
    
  3. Create 'user' table with a foreign key to table 'rbac_role'. You can see an example of yii2 migrations in examples\migrations directory., (*11)

  4. Generate the model and CRUD of 'user' table using Gii
  5. Implements juliardi\simplerbac\base\UserRbacInterface in your User model. You can see an example of yii2 model in examples\models directory.
  6. You can now access it by visiting :
http://yourproject.dev/index.php?r=simplerbac

Usage

Once the extension is configured, simply use it by :, (*12)

  1. Extends juliardi/simplerbac/base/Controller in your controller
  2. That's all. You can set your access rules for your action by accessing :
http://yourproject.dev/index.php?r=simplerbac

The Versions

01/08 2017
26/07 2016
26/07 2016