PHPackages                             phuongdev89/yii2-user-role - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. phuongdev89/yii2-user-role

ActiveYii2-extension[Authentication &amp; Authorization](/categories/authentication)

phuongdev89/yii2-user-role
==========================

This is simple user role for Yii2

1.2.0(3y ago)0120MITPHP

Since Jan 10Pushed 2y agoCompare

[ Source](https://github.com/phuongdev89/yii2-user-role)[ Packagist](https://packagist.org/packages/phuongdev89/yii2-user-role)[ RSS](/packages/phuongdev89-yii2-user-role/feed)WikiDiscussions master Synced 1mo ago

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

yii2-user-role
==============

[](#yii2-user-role)

Install
-------

[](#install)

```
composer require phuongdev89/yii2-user-role "@dev"

```

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

[](#configuration)

### in `backend/config/main.php` or `app/config/web.php`

[](#in-backendconfigmainphp-or-appconfigwebphp)

```
[php]
'modules' => [
    'user' => [
        'class' => 'dektrium\user\Module',
        'modelMap' => [
            'User' => 'phuongdev89\role\models\User',//IMPORTANT & REQUIRED, change to your User model if overridden
            'LoginForm' => 'phuongdev89\role\models\forms\LoginForm',//IMPORTANT & REQUIRED, change to your User model if overridden
        ],
    ],
   'role' => [
        'class' => 'phuongdev89\role\Module',
        'controllers' => [
            //namespaces of controllers you want to control
            'app\controllers',
            'phuongdev89\role\controllers',
        ],
    ],
],

```

### in `console/config/main.php` or `app/config/console.php`

[](#in-consoleconfigmainphp-or-appconfigconsolephp)

```
'controllerMap' => [
    ...
    'migrate'  => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationPath' => [
            '@console/migrations',
            '@vendor/dektrium/yii2-user/migrations',
            '@phuongdev89/role/migrations',
        ],
    ],
],

```

### Run migrate

[](#run-migrate)

```
php yii migrate/up

```

Usage
-----

[](#usage)

### in model User, if you override it

[](#in-model-user-if-you-override-it)

```
class User extends \phuongdev89\role\models\User

```

### In every controller you want to check role

[](#in-every-controller-you-want-to-check-role)

```
class SiteController extends Controller {

    public function behaviors() {
        return [
            'verbs' => [
            ....
            ],
            'role'  => [
                'class'   => RoleFilter::className(),
                'name'    => 'Trang chủ', //NOT REQUIRED, only if you want to translate
                'actions' => [
                    'create', //without translate
                    'index' => 'Danh sách', //with translated, which will display on role _form
                ],
            ],
        ];
    }
}

```

### In everywhere:

[](#in-everywhere)

```
use phuongdev89\role\helpers\RoleChecker;
...
//public static function isAuth($controller, $action = '', $role_id = null)
$boolean = RoleChecker::isAuth(SiteController::className(), 'index', Yii::$app->user->identity->getRoleId());

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

1217d ago

### Community

Maintainers

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

---

Top Contributors

[![phuongdev89](https://avatars.githubusercontent.com/u/7648033?v=4)](https://github.com/phuongdev89 "phuongdev89 (2 commits)")

---

Tags

yii2user rolerole base

### Embed Badge

![Health badge](/badges/phuongdev89-yii2-user-role/health.svg)

```
[![Health](https://phpackages.com/badges/phuongdev89-yii2-user-role/health.svg)](https://phpackages.com/packages/phuongdev89-yii2-user-role)
```

###  Alternatives

[kotchuprik/yii2-instagram-authclient

Instagram extenion for using via yii2-authclient

2048.5k](/packages/kotchuprik-yii2-instagram-authclient)[rmrevin/yii2-ulogin

Extension for yii2 ulogin integration

1811.9k](/packages/rmrevin-yii2-ulogin)[kakadu-dev/yii2-jwt-auth

Extension provide JWT auth for Yii2

105.8k](/packages/kakadu-dev-yii2-jwt-auth)

PHPackages © 2026

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