PHP code example of lirriella / yii2-users

1. Go to this page and download the library: Download lirriella/yii2-users 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/ */

    

lirriella / yii2-users example snippets


php composer.phar 

'user' => [
    'identityClass' => 'lirriella\users\models\User',
    'enableAutoLogin' => true,
    'loginUrl' => ['/login'],
],
'authClientCollection' => [
    'class' => 'yii\authclient\Collection',
    'clients' => [
        'vkontakte' => [
            'class' => 'budyaga\users\components\oauth\VKontakte',
            'clientId' => 'XXX',
            'clientSecret' => 'XXX',
            'scope' => 'email'
        ],
        'google' => [
            'class' => 'lirriella\users\components\oauth\Google',
            'clientId' => 'XXX',
            'clientSecret' => 'XXX',
        ],
        'facebook' => [
            'class' => 'budyaga\users\components\oauth\Facebook',
            'clientId' => 'XXX',
            'clientSecret' => 'XXX',
        ],
        'github' => [
            'class' => 'budyaga\users\components\oauth\GitHub',
            'clientId' => 'XXX',
            'clientSecret' => 'XXX',
            'scope' => 'user:email, user'
        ],
        'linkedin' => [
            'class' => 'budyaga\users\components\oauth\LinkedIn',
            'clientId' => 'XXX',
            'clientSecret' => 'XXX',
        ],
        'live' => [
            'class' => 'budyaga\users\components\oauth\Live',
            'clientId' => 'XXX',
            'clientSecret' => 'XXX',
        ],
        'yandex' => [
            'class' => 'budyaga\users\components\oauth\Yandex',
            'clientId' => 'XXX',
            'clientSecret' => 'XXX',
        ],
        'twitter' => [
            'class' => 'budyaga\users\components\oauth\Twitter',
            'consumerKey' => 'XXX',
            'consumerSecret' => 'XXX',
        ],
    ],
],
'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
        '/signup' => '/user/user/signup',
        '/login' => '/user/user/login',
        '/logout' => '/user/user/logout',
        '/requestPasswordReset' => '/user/user/request-password-reset',
        '/resetPassword' => '/user/user/reset-password',
        '/profile' => '/user/user/profile',
        '/retryConfirmEmail' => '/user/user/retry-confirm-email',
        '/confirmEmail' => '/user/user/confirm-email',
        '/unbind/<id:[\w\-]+>' => '/user/auth/unbind',
        '/oauth/<authclient:[\w\-]+>' => '/user/auth/index'
    ],
],
'authManager' => [
    'class' => 'yii\rbac\DbManager',
],

'modules' => [
    'user' => [
        'class' => 'budyaga\users\Module',
        'userPhotoUrl' => 'http://example.com/uploads/user/photo',
        'userPhotoPath' => '@frontend/web/uploads/user/photo'
    ],
],

<?= AuthorizationWidget::widget() 

'modules' => [
    'user' => [
        'class' => 'lirriella\users\Module',
        'customViews' => [
            'login' => '@app/views/site/login'
        ],
        'customMailViews' => [
            'confirmChangeEmail' => '@app/mail/confirmChangeEmail' //in this case you have to create files confirmChangeEmail-html.php and confirmChangeEmail-text.php in mail folder
        ]
    ],
],