2017 © Pedro Peláez
 

yii2-extension yii2-user

user extension for Yii2

image

maximkozhin/yii2-user

user extension for Yii2

  • Thursday, May 18, 2017
  • by maximkozhin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

User Extension for Yii2

User Extension for Yii2, (*1)

Via composer

add to your 'require' section in file 'composer.json', (*2)

 "require": {
       ...
        "maximkozhin/yii2-user": "*"
    },

or run command, (*3)

$ composer require maximkozhin/yii2-user

1. Migration | Миграция

run migration:, (*4)

yii migrate/up --migrationPath=@vendor/maximkozhin/yii2-user/migrations

to revert migration run:, (*5)

yii migrate/down --migrationPath=@vendor/maximkozhin/yii2-user/migrations

2. Configuration | Конфигурация

Copy files into 'your-repo' directory., (*6)

after add into components, (*7)

...
'componetns' => [
    ...
    'user' => [
            'class' => 'maximkozhin\user\components\User',
            'identityClass' => 'maximkozhin\user\models\User',
            'loginUrl'  => 'url/alias/to/login'
            'logoutUrl' => 'url/alias/to/logout'
        ],
    ...
]
...

3. Usage | Использование

Into your code you may use, (*8)

User is guest, (*9)

Yii::$app->user->is('guest');

User is logged in, (*10)

Yii::$app->user->is('user');

3. Usage Role | Использование ролей

To create another role typo an alias of role and name of role., (*11)

$alias = 'admin';
\maximkozhin\user\models\Role::add($alias, 'Администратор');

Add this role for user, (*12)

/** @var \maximkozhin\user\models\User $user*/
$user->addRole($alias);

after that you may check user role, (*13)

Yii::$app->user->is('admin');
or
$user->is('admin');

to delete role for user, (*14)

/** @var \maximkozhin\user\models\User $user*/
$user->deleteRole($alias);

4. Module | Модуль пользователей

...
'modules' => [
    ...
    'user-module-name' => [
        'class' => 'maximkozhin\user\modules\user\Module',
    ],
    ...
],
...

The Versions

18/05 2017

dev-master

9999999-dev

user extension for Yii2

  Sources   Download

MIT

The Requires

 

by Maxim Kozhin

user extension yii2

18/05 2017

1.0.0

1.0.0.0

user extension for Yii2

  Sources   Download

MIT

The Requires

 

by Maxim Kozhin

user extension yii2