Yii2-user
A flexible and quick user module for Yii2
Yii2-user is a independent module that include user registration, authentication and management. It means that installation requires minimal steps. Only one configuration step should be taken and you are ready to have user management on your Yii2 website.
Getting started
1. Download
Yii2-user can be installed using composer. Run following command to download and install Yii2-user:
composer require zhongq0930/yii2-user
2. Configure
Once the extension is installed, simply modify your application configuration as follows. If a module ID is the same as an application component ID, using an anonymous function instead. see https://www.yiiframework.com/doc/guide/2.0/en/structure-applications#bootstrap.
'bootstrap' => [
function () {
return Yii::$app->getModule('user');
}
],
'modules' => [
'user' => [
'class' => 'zhongq0930\user\Module',
],
],
NOTE: If you use different layout for login and register page, you can config the
withAppLayout
property with false.
3. Update database schema
The last thing you need to do is updating your database schema by applying the
migrations. Make sure that you have properly configured db
application component
and run the following command:
$ php yii migrate --migrationPath=@vendor/zhongq0930/yii2-user/src/migrations
Now, you had installed yii2-user, try it by access your website.
Configuration
All available configuration options are listed below with their default values.
admins (Type: array, Default [])
Specify the username of administrator who can access a page that manager registered users or create a new user account.
adminPermission (Type: string, Default null)
Specify the permission that can access a page that manager registered users or create a new user account, user who have this permission can access this page. This option is not available now.
withAppLayout (Type: boolean, Default true)
If you want to use different layout between application and login/register page, configure it with false.
enableEmailVerify (Type: boolean, Default true)
If this option is to false, user can not login without confirm email.
enableRegister (Type: boolean, Default true)
If this option is to false, user can not register.