PHPackages                             panix/mod-rbac - 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. panix/mod-rbac

ActivePixelion-module

panix/mod-rbac
==============

RBAC management module

0238PHPCI failing

Since Feb 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/andrtechno/mod-rbac)[ Packagist](https://packagist.org/packages/panix/mod-rbac)[ RSS](/packages/panix-mod-rbac/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Module RBAC provides a web interface for advanced access control and includes following features:

- Allows CRUD operations for roles, permissions, rules
- Allows to assign multiple roles or permissions to the user
- Allows to create console migrations

[![Latest Stable Version](https://camo.githubusercontent.com/b312c4eb1c78741fcf74b50a88331b26a86806f24c42f0ab2ff593eb870c5e74/68747470733a2f2f706f7365722e707567782e6f72672f70616e69782f6d6f642d726261632f762f737461626c65)](https://packagist.org/packages/panix/mod-rbac)[![Latest Unstable Version](https://camo.githubusercontent.com/25798e4a6c5f94b836f9346d7256b13578d1cf0fb370df4e7b4e7fe65e4db5c7/68747470733a2f2f706f7365722e707567782e6f72672f70616e69782f6d6f642d726261632f762f756e737461626c65)](https://packagist.org/packages/panix/mod-rbac)[![Total Downloads](https://camo.githubusercontent.com/d54915d06b55b9c2e4f75800d263447b85759f52825b5da15ead0fa98883fc7f/68747470733a2f2f706f7365722e707567782e6f72672f70616e69782f6d6f642d726261632f646f776e6c6f616473)](https://packagist.org/packages/panix/mod-rbac)[![Monthly Downloads](https://camo.githubusercontent.com/2fcbe803f8ca148aa71e77bf068169a6518cb99083ffbae1d52d1b96e8a7bc28/68747470733a2f2f706f7365722e707567782e6f72672f70616e69782f6d6f642d726261632f642f6d6f6e74686c79)](https://packagist.org/packages/panix/mod-rbac)[![Daily Downloads](https://camo.githubusercontent.com/06e40f61f557f0139b79acccae82193f9924447ecf403368fb370bcb00b9cec0/68747470733a2f2f706f7365722e707567782e6f72672f70616e69782f6d6f642d726261632f642f6461696c79)](https://packagist.org/packages/panix/mod-rbac)[![License](https://camo.githubusercontent.com/5503c79294ab26b40a61beec4739e6d5cb1563cd5469569bdf067f65610af900/68747470733a2f2f706f7365722e707567782e6f72672f70616e69782f6d6f642d726261632f6c6963656e7365)](https://packagist.org/packages/panix/mod-rbac)

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

[](#installation)

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

Either run

```
php composer require --prefer-dist panix/mod-rbac "*"

```

or add

```
"panix/mod-rbac": "*"

```

to the require section of your composer.json.

Usage
-----

[](#usage)

Once the extension is installed, simply modify your application configuration as follows:

```
return [
    'modules' => [
        'rbac' => [
            'class' => 'panix\mod\rbac\Module',
        ],
    ],
    'components' => [
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
            'defaultRoles' => ['guest', 'user'],
        ],
    ],
];
```

After you downloaded and configured Yii2-rbac, the last thing you need to do is updating your database schema by applying the migration:

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

You can then access Auth manager through the following URL:

```
http://localhost/path/to/index.php?r=rbac/
http://localhost/path/to/index.php?r=rbac/route
http://localhost/path/to/index.php?r=rbac/permission
http://localhost/path/to/index.php?r=rbac/role
http://localhost/path/to/index.php?r=rbac/assignment

```

or if you have enabled pretty URLs, you may use the following URL:

```
http://localhost/path/to/index.php/rbac
http://localhost/path/to/index.php/rbac/route
http://localhost/path/to/index.php/rbac/permission
http://localhost/path/to/index.php/rbac/role
http://localhost/path/to/index.php/rbac/assignment

```

**Applying rules:**

1. For applying rules only for `controller` add the following code:

```
use panix\mod\rbac\filters\AccessControl;

class AdminController extends Controller
{
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::class,
                'allowActions' => [
                    'index',
                    // The actions listed here will be allowed to everyone including guests.
                ]
            ],
        ];
    }
}
```

2. For applying rules for `module` add the following code:

```
use Yii;
use panix\mod\rbac\filters\AccessControl;

/**
 * Class Module
 */
class Module extends \yii\base\Module
{
    /**
     * @return array
     */
    public function behaviors()
    {
        return [
            AccessControl::class
        ];
    }
}
```

3. Also you can apply rules via main configuration:

```
// apply for single module

'modules' => [
    'rbac' => [
        'class' => 'panix\mod\rbac\Module',
        'as access' => [
            'class' => panix\mod\rbac\filters\AccessControl::class
        ],
    ]
]

// or apply globally for whole application

'modules' => [
    ...
],
'components' => [
    ...
],
'as access' => [
    'class' => panix\mod\rbac\filters\AccessControl::class,
    'allowActions' => [
        'site/*',
        'admin/*',
        // The actions listed here will be allowed to everyone including guests.
        // So, 'admin/*' should not appear here in the production, of course.
        // But in the earlier stages of your development, you may probably want to
        // add a lot of actions here until you finally completed setting up rbac,
        // otherwise you may not even take a first step.
    ]
 ],
```

Migrations
----------

[](#migrations)

You can create the console migrations for creating/updating RBAC items.

### Module setup

[](#module-setup)

To be able create the migrations, you need to add the following code to your console application configuration:

```
// console.php
'modules' => [
    'rbac' => [
        'class' => 'panix\mod\rbac\ConsoleModule'
    ]
]
```

### Methods

[](#methods)

1. `createPermission()`: creating a permission
2. `updatePermission()`: updating a permission
3. `removePermission()`: removing a permission
4. `createRole()`: creating a role
5. `updateRole()`: updating a role
6. `removeRole()`: removing a role
7. `createRule()`: creating a rule
8. `updateRule()`: updating a rule
9. `removeRule()`: removing a rule
10. `addChild()`: creating a child
11. `removeChild()`: removing a child
12. `assign()`: assign a role to a user

> You can see a complex example of migration [here.](https://github.com/yii2mod/base/blob/master/rbac/migrations/m160722_085418_init.php)

### Applying Migrations

[](#applying-migrations)

To upgrade a database to its latest structure, you should apply all available new migrations using the following command:

```
$ php cmd rbac/migrate
```

### Reverting Migrations

[](#reverting-migrations)

To revert (undo) one or multiple migrations that have been applied before, you can run the following command:

```
$ php cmd rbac/migrate/down     # revert the most recently applied migration
$ php cmd rbac/migrate/down 3   # revert the most 3 recently applied migrations
```

### Redoing Migrations

[](#redoing-migrations)

Redoing migrations means first reverting the specified migrations and then applying again. This can be done as follows:

```
$ php cmd rbac/migrate/redo     # redo the last applied migration
$ php cmd rbac/migrate/redo 3   # redo the last 3 applied migrations
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f081670109ead0bd6a80aa3af5e9ef9fdcacecdaa3d5a9c1281eed523d09e455?d=identicon)[andrtechno](/maintainers/andrtechno)

---

Top Contributors

[![andrtechno](https://avatars.githubusercontent.com/u/6948026?v=4)](https://github.com/andrtechno "andrtechno (55 commits)")

### Embed Badge

![Health badge](/badges/panix-mod-rbac/health.svg)

```
[![Health](https://phpackages.com/badges/panix-mod-rbac/health.svg)](https://phpackages.com/packages/panix-mod-rbac)
```

PHPackages © 2026

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