Download the PHP package phuongdev89/yii2-user-role without Composer
On this page you can find all versions of the php package phuongdev89/yii2-user-role. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download phuongdev89/yii2-user-role
More information about phuongdev89/yii2-user-role
Files in phuongdev89/yii2-user-role
Download phuongdev89/yii2-user-role
More information about phuongdev89/yii2-user-role
Files in phuongdev89/yii2-user-role
Vendor phuongdev89
Package yii2-user-role
Short Description This is simple user role for Yii2
License MIT
Package yii2-user-role
Short Description This is simple user role for Yii2
License MIT
Please rate this library. Is it a good library?
Informations about the package yii2-user-role
yii2-user-role
Install
composer require phuongdev89/yii2-user-role "@dev"
Configuration
in backend/config/main.php
or app/config/web.php
[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
'controllerMap' => [
...
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationPath' => [
'@console/migrations',
'@vendor/dektrium/yii2-user/migrations',
'@phuongdev89/role/migrations',
],
],
],
Run migrate
php yii migrate/up
Usage
in model User, if you override it
class User extends \phuongdev89\role\models\User
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:
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());
All versions of yii2-user-role with dependencies
PHP Build Version
Package Version
The package phuongdev89/yii2-user-role contains the following files
Loading the files please wait ....