PHP code example of yii2mod / yii2-user

1. Go to this page and download the library: Download yii2mod/yii2-user library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yii2mod / yii2-user example snippets


'params' => [
   'user.passwordResetTokenExpire' => 3600
]

'user' => [
    'identityClass' => 'yii2mod\user\models\UserModel',
    // for update last login date for user, you can call the `afterLogin` event as follows
    'on afterLogin' => function ($event) {
        $event->identity->updateLastLogin();
    }
],



use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $user */

$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/password-reset', 'token' => $user->password_reset_token]);

    /**
     * @return array
     */
    public function actions()
    {
        return [
            'login' => [
                'class' => 'yii2mod\user\actions\LoginAction'
            ],
            'logout' => [
                'class' => 'yii2mod\user\actions\LogoutAction'
            ],
            'signup' => [
                'class' => 'yii2mod\user\actions\SignupAction'
            ],
            'request-password-reset' => [
                'class' => 'yii2mod\user\actions\RequestPasswordResetAction'
            ],
            'password-reset' => [
                'class' => 'yii2mod\user\actions\PasswordResetAction'
            ],
        ];
    }

    /**
     * @return array
     */
    public function actions()
    {
        return [
            'login' => [
                'class' => 'yii2mod\user\actions\LoginAction',
                'on beforeLogin' => function ($event) {
                    // your custom code
                },
                'on afterLogin' => function ($event) {
                    // your custom code
                },
            ],
            'logout' => [
                'class' => 'yii2mod\user\actions\LogoutAction',
                'on beforeLogout' => function ($event) {
                    // your custom code
                },
                'on afterLogout' => function ($event) {
                    // your custom code
                },
            ],
            'signup' => [
                'class' => 'yii2mod\user\actions\SignupAction',
                'on beforeSignup' => function ($event) {
                    // your custom code
                },
                'on afterSignup' => function ($event) {
                    // your custom code
                },
            ],
            'request-password-reset' => [
                'class' => 'yii2mod\user\actions\RequestPasswordResetAction',
                'on beforeRequest' => function ($event) {
                    // your custom code
                },
                'on afterRequest' => function ($event) {
                    // your custom code
                },
            ],
            'password-reset' => [
                'class' => 'yii2mod\user\actions\PasswordResetAction',
                'on beforeReset' => function ($event) {
                    // your custom code
                },
                'on afterReset' => function ($event) {
                    // your custom code
                },
            ],
        ];
    }


    return [
        'id' => 'app-console',
        'modules' => [
            'user' => [
                'class' => 'yii2mod\user\ConsoleModule',
            ],
        ],


return [
    'components' => [
        'i18n' => [
            'translations' => [
                'yii2mod.user' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@yii2mod/user/messages',
                ],
                // ...
            ],
        ],
        // ...
    ],
    // ...
];

php composer.phar 

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