itstructure/yii2-rbac-module Module to manage roles and permissions for the Yii2 Framework.

rbacmodule

Yii2 RBAC module

1 Introduction

Latest Stable Version Latest Unstable Version License Total Downloads Build Status Scrutinizer Code Quality

Rbac module -- Module for the Yii2 framework, which provides management with the next data:

  • Roles
  • Permissions

2 Dependencies

  • php >= 7.1
  • composer
  • MySql >= 5.5

3 Installation

3.1 General from remote repository

Via composer:

composer require "itstructure/yii2-rbac-module": "^3.0.0"

or in section require of composer.json file set the following:

"require": {
    "itstructure/yii2-rbac-module": "^3.0.0"
}

and command composer install, if you install yii2 project extensions first,

or command composer update, if all yii2 project extensions are already installed.

3.2 If you are testing this package from local server directory

In application composer.json file set the repository, like in example:

"repositories": [
    {
        "type": "path",
        "url": "../yii2-rbac-module",
        "options": {
            "symlink": true
        }
    }
],

Here,

yii2-rbac-module - directory name, which has the same directory level like application and contains yii2 rbac module.

Then run command:

composer require itstructure/yii2-rbac-module:dev-master --prefer-source

3.3 Addition components

In accordance with the documentation for Yii2, set authManager for application:

'components' => [
    'authManager' => [
        'class' => 'yii\rbac\DbManager',
    ],
    // ...
],

In accordance with the documentation for Yii2, run command:

yii migrate --migrationPath=@yii/rbac/migrations

4 Usage

4.1 Main properties

  • The name of module: rbac
  • The namespace for used classes: Itstructure\RbacModule.
  • The alias to access in to module root directory: @rbac.
  • There is not a layout ! It's taken from application layout main by default or how it is configured. You cat set layout attribute in module by custom.
  • View component is taken by default from the framework like yii\web\View. You cat set view component in module by custom.

4.2 Application config

Base application config must be like in example below:

use Itstructure\RbacModule\Module;
use Itstructure\RbacModule\controllers\{RoleController, PermissionController, ProfileController};
'modules' => [
    'rbac' => [
        'class' => Module::class,
        'controllerMap' => [
            'roles' => RoleController::class,
            'permissions' => PermissionController::class,
            'profiles' => ProfileController::class,
        ],
    ],
],

4.3 Useful module attributes

  • loginUrl - set url to be redirected if you are not authorized.
  • accessRoles - The roles of users who are allowed access to work with this package.
  • urlPrefix - Url prefix for redirect and view links (Default is empty).
  • urlPrefixNeighbor - Url prefix for redirect and view links of neighbor entity (Default is empty).

License

Copyright © 2018 Andrey Girnik girnikandrey@gmail.com.

Licensed under the MIT license. See LICENSE.txt for details.

Changelog

CHANGE LOG:

3.0.0 August 5, 2018:

  • Code fixes according with the PSR standards.
  • Rename RolesController to RoleController.
  • Rename PermissionsController to PermissionController.
  • Rename ProfilesController to ProfileController.

2.0.0 August 1, 2018:

  • Created classes to assign roles for profiles.
  • Code optimization.

1.1.0 June 16, 2018:

  • Add urlPrefix parameter in to BaseController for redirect and view links.

1.0.0 May 13, 2018:

  • Create module, which provides management with the next data:
    • Roles
    • Permissions
  • Created documentation.

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



3.0.0 is the latest of 4 releases



MIT license
Stats
1 github stars & 0 github forks
0 downloads in the last day
0 downloads in the last 30 days
32 total downloads