PHPackages                             ahmadasjad/yii2-rbac-plus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ahmadasjad/yii2-rbac-plus

ActiveYii2-extension

ahmadasjad/yii2-rbac-plus
=========================

Database role base access control manager for yii2

1.0.7(9y ago)122Apache-2.0PHP

Since Jul 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ahmadasjad/yii2-rbac-plus)[ Packagist](https://packagist.org/packages/ahmadasjad/yii2-rbac-plus)[ RSS](/packages/ahmadasjad-yii2-rbac-plus/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (9)Used By (0)

yii2-rbac-plus
==============

[](#yii2-rbac-plus)

[![Latest Stable Version](https://camo.githubusercontent.com/cf0a2a82aa548dec8db3480e29cb476ca8d14f9f96a7dd0b0123b6929f73fc6f/68747470733a2f2f706f7365722e707567782e6f72672f61686d616461736a61642f796969322d726261632d706c75732f762f737461626c65)](https://packagist.org/packages/ahmadasjad/yii2-rbac-plus)[![License](https://camo.githubusercontent.com/d1c5190b8adf70fcc5011cbd89c447225f84b6229a1f96794013698edd475dd5/68747470733a2f2f706f7365722e707567782e6f72672f61686d616461736a61642f796969322d726261632d706c75732f6c6963656e7365)](https://packagist.org/packages/ahmadasjad/yii2-rbac-plus)[![Total Downloads](https://camo.githubusercontent.com/00223c5aeb907ae9e44d683abd71234bf38e106f41d038a2a9eff19539782e47/68747470733a2f2f706f7365722e707567782e6f72672f61686d616461736a61642f796969322d726261632d706c75732f646f776e6c6f616473)](https://packagist.org/packages/ahmadasjad/yii2-rbac-plus)[![Monthly Downloads](https://camo.githubusercontent.com/5ead423eb10fa1834e008fa2e9bdf96f70236ef0228224f5e6563c6f6a880ddb/68747470733a2f2f706f7365722e707567782e6f72672f61686d616461736a61642f796969322d726261632d706c75732f642f6d6f6e74686c79)](https://packagist.org/packages/ahmadasjad/yii2-rbac-plus)[![Daily Downloads](https://camo.githubusercontent.com/48b2eb5dde8e617edb0437b7759e964556d2106157fb9233834bc4d75ed5093a/68747470733a2f2f706f7365722e707567782e6f72672f61686d616461736a61642f796969322d726261632d706c75732f642f6461696c79)](https://packagist.org/packages/ahmadasjad/yii2-rbac-plus)

Database role base access control manager for yii2 Actually, this is duplicate repo of Due to not being active and pulling request of contributor or listening to them, I created this one.

Features
--------

[](#features)

- CRUD operations for roles, permissions and rules
- Allows to assign multiple roles to user
- Nice views to intergrate right away
- Integrated with [Yii2-user-plus](https://github.com/ahmadasjad/yii2-user-plus) - flexible user management module

[![Yii2 RBAC manager](https://camo.githubusercontent.com/0c4b0758e73a5b6ac7ffb18bf7321537e5b03e0b43f17d2244438688626c606e/687474703a2f2f7331372e706f7374696d672e6f72672f387037696462396a7a2f73637265656e636170747572655f66617374616e64667572696f75735f6465765f617070735f746573745f757365722e706e67)](https://camo.githubusercontent.com/0c4b0758e73a5b6ac7ffb18bf7321537e5b03e0b43f17d2244438688626c606e/687474703a2f2f7331372e706f7374696d672e6f72672f387037696462396a7a2f73637265656e636170747572655f66617374616e64667572696f75735f6465765f617070735f746573745f757365722e706e67)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist ahmadasjad/yii2-rbac-plus "*"

```

or add

```
"ahmadasjad/yii2-rbac-plus": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

1. Let 's add into modules config in your main config file

```
'components' => [
    'authManager' => [
        'class' => 'yii\rbac\DbManager',
    ],
],
'modules' => [
    'rbac' =>  [
        'class' => 'ahmadasjad\rbacplus\Module'
    ]
]

```

Next, update the database schema

```
$ php yii migrate/up --migrationPath=@yii/rbac/migrations

```

Ok. That's done. Avaiable route now:

- /rbac/rule
- /rbac/permission
- /rbac/role
- /rbac/assignment

2. The module configuration avaible:

```
'modules' => [
    'rbac' =>  [
        'class' => 'ahmadasjad\rbacplus\Module',
        'userModelClassName'=>null,
        'userModelIdField'=>'id',
        'userModelLoginField'=>'username',
        'userModelLoginFieldLabel'=>null,
        'userModelExtraDataColumls'=>null,
        'beforeCreateController'=>null,
        'beforeAction'=>null
    ]
]

```

- **userModelClassName**: The user model class.
    If you not set or set null, **RBAC Plus** will be get from `Yii::$app->getUser()->identityClass`
- **userModelIdField**: The user model id field.
    Default id field is 'id', you must set this config if primary key of user table in database is not 'id'
- **userModelLoginField** The user model login field.
    Default login field is 'username'. Maybe you use email field or something other for login. So you must change this config
- **userModelLoginFieldLabel** The user model login field label.
    If you set null the label will get from `$userModelClass->attributeLabels()[$userModelLoginField]`
- **userModelExtraDataColumls** The extra data columns you want to show in user assign views.
    The default in assignment data gridview just display id and login column data. if you want to add created\_at column you can add

```
'userModelExtraDataColumls'=>[
    [
        'attributes'=>'created_at',
        'value'=>function($model){
            return date('m/d/Y', $model->created_at);
        }
    ]
]
```

- **beforeCreateController** The callable before create all controller of **Rbac Plus** module. The default it is null. You need config this when you want to restrict access to **Rbac Plus** module.
    Example:

```
'beforeCreateController'=>function($route){
    /**
    *@var string $route The route consisting of module, controller and action IDs.
    */
}
```

- **beforeAction**The callable before action of all controller in **Rbac Plus** module.
    The default it is null. You need config this when you want to restrict access to any action in some controller of **Rbac Plus** module
    Example:

```
'beforeAction'=>function($action){
    /**
    *@var yii\base\Action $action the action to be executed.
    */
}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~75 days

Recently: every ~124 days

Total

8

Last Release

3417d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7730b61d24eb0885673bcaa4a9662fa1b2e0e7bbd56d42acfd12a33f06aa21f4?d=identicon)[ahmadasjad](/maintainers/ahmadasjad)

---

Top Contributors

[![johnitvn](https://avatars.githubusercontent.com/u/8359652?v=4)](https://github.com/johnitvn "johnitvn (52 commits)")[![ahmadasjad](https://avatars.githubusercontent.com/u/7436311?v=4)](https://github.com/ahmadasjad "ahmadasjad (7 commits)")[![Evgen1986](https://avatars.githubusercontent.com/u/10276586?v=4)](https://github.com/Evgen1986 "Evgen1986 (2 commits)")[![max-dreamsoft](https://avatars.githubusercontent.com/u/16354564?v=4)](https://github.com/max-dreamsoft "max-dreamsoft (1 commits)")[![MikleUA](https://avatars.githubusercontent.com/u/8805154?v=4)](https://github.com/MikleUA "MikleUA (1 commits)")[![pceuropa](https://avatars.githubusercontent.com/u/9319670?v=4)](https://github.com/pceuropa "pceuropa (1 commits)")

---

Tags

rbacyii2yii2-extensionyii2-rbac

### Embed Badge

![Health badge](/badges/ahmadasjad-yii2-rbac-plus/health.svg)

```
[![Health](https://phpackages.com/badges/ahmadasjad-yii2-rbac-plus/health.svg)](https://phpackages.com/packages/ahmadasjad-yii2-rbac-plus)
```

###  Alternatives

[johnitvn/yii2-settings

Yii2 settings with database module with GUI manager supported

215.8k](/packages/johnitvn-yii2-settings)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
