PHPackages                             gozoro/yii2-rbac-console - 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. [CLI &amp; Console](/categories/cli)
4. /
5. gozoro/yii2-rbac-console

ActiveYii2-extension[CLI &amp; Console](/categories/cli)

gozoro/yii2-rbac-console
========================

RBAC configuration and managment tool in the console.

v1.0.2(2y ago)0121MITPHPPHP &gt;=5.5.9

Since Apr 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/gozoro/yii2-rbac-console)[ Packagist](https://packagist.org/packages/gozoro/yii2-rbac-console)[ Docs](https://github.com/gozoro/yii2-rbac-console)[ RSS](/packages/gozoro-yii2-rbac-console/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

yii2-rbac-console
=================

[](#yii2-rbac-console)

RBAC configuration and managment tool in the console.

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

[](#installation)

```
composer require gozoro/yii2-rbac-console

```

Preparation
-----------

[](#preparation)

Create console controller `commands\RbacController.php`.

```
namespace app\commands;

class RbacController extends \gozoro\yii2\rbac\console\RbacController;
{
	public function findIdentityByUsername($username)
	{
		//TODO:: Return an instance of the class with interface \yii\web\Identity

		// example:
		//return UserIdentity::find()->where(['username'=>$username])->one();
	}

	public function findIdentityById($userId)
	{
		//TODO:: Return an instance of the class with interface \yii\web\Identity

		// example:
		//return UserIdentity::find()->where(['id'=>$userId])->one();
	}
}
```

Controller actions
------------------

[](#controller-actions)

- `./yii rbac/init` Performs initial RBAC configuration (remembers user roles, deletes all data, revert data from the config, restores users roles). You can use it after adding new roles or removing not need roles.
- `rbac/show-config` Displays config (default config: `@app/config/rbac.php`).
- `rbac/roles` Displays a list of roles from AuthManager.
- `rbac/permissions` Displays a list of permissions from AuthManager.
- `rbac/rules` Displays a list of rules from AuthManager.
- `rbac/show` (default) Displays a list of roles and users.
- `rbac/show-user` Displays roles and permissions of user.
- `rbac/assign` Assigns a role (or a permission) to a user.
- `rbac/unassign` Revokes role or permission from a user.
- `rbac/unassign-all` Revokes all roles and permissions from a user.

Configuration
-------------

[](#configuration)

Create config `@app/config/rbac.php`.

Example:

```
 return [
 	// Permission list
 	'permissions' =>[
 		'read' => 'permissions for read something',   // permission_name => description
    	'write' => 'permissions for write something', // permission_name => description

		'permission_master' => $permision, // permission_name => permission object
		'permission_slave' => [ // permission_name => permission as array
			'name' => ...,
			'description' => ...,
			'data' => ...,
		],
 	],

	// Role list
 	'roles' => [
 		'role_admin' => 'Administrator role', // role_name => description
 		'role_manager' => 'Manager role',     // role_name => description
		'role_viewer' => $role, // role_name => role_object
		'role_something' => [ // role_name => role as array
			'name' => ...,
			'description' => ...,
			'data' => ...,
		],

 	],

	// Rule list
	'rules' => [
		\WriteRule:class => ['write'], // rule for permission "write"
		$rule => ['write', 'read'], // rule object for permissions "write" and "read"
	],

     // Mapping roles to permissions
	'access' => [
		'permission_master' => ['permission_slave'],
		'role_admin' => ['read', 'write'], // array of permissions
		'role_manager' => ['read', 'permission_master'],
	],
];
```

Use command `./yii rbac/init` to initialize or re-initialize RBAC-scheme from config.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity36

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

775d ago

### Community

Maintainers

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

---

Top Contributors

[![gozoro](https://avatars.githubusercontent.com/u/13768280?v=4)](https://github.com/gozoro "gozoro (13 commits)")

---

Tags

consoleauthrbacyii2authmanager

### Embed Badge

![Health badge](/badges/gozoro-yii2-rbac-console/health.svg)

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

###  Alternatives

[samdark/yii2-webshell

A web shell that allows to run yii console commands and create your own commands.

22981.5k1](/packages/samdark-yii2-webshell)[vova07/yii2-console-runner-extension

An extension for running console commands on background in Yii framework.

88202.2k2](/packages/vova07-yii2-console-runner-extension)[toriphes/yii2-console-runner

Runs console command in yii web application

29240.1k](/packages/toriphes-yii2-console-runner)[fedemotta/yii2-cronjob

Yii2 extension to help in the creation of automated console scripts

2233.5k](/packages/fedemotta-yii2-cronjob)

PHPackages © 2026

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