PHP code example of su-pn-psu / yii2-user

1. Go to this page and download the library: Download su-pn-psu/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/ */

    

su-pn-psu / yii2-user example snippets


    'modules' => [
        ...
        'user' => [ //module id = 'user' only
            'class' => 'anda\user\Module',
            'loginBy' => 'db', //db or ldap (ldap not work)
            'userUploadDir' => '@uploads', //Base uploads Directory
            'userUploadUrl' => '/uploads', //Url of userUploadDir
            'userUploadPath' => 'user', //path after upload directory
            'admins' => ['admin', 'root'] //list of username for manage users
        ],
        ...
    ],
    'components' => [
        ...
        'user' => [
            'identityClass' => 'anda\user\models\User',
        ],
        ...
    ],

Yii::$app->user->isGuest ?
    ['label' => 'Sign in', 'url' => ['/user/auth/login']] :
    ['label' => 'Sign out (' . Yii::$app->user->identity->username . ')',
        'url' => ['/user/auth/logout'],
        'linkOptions' => ['data-method' => 'post']],
['label' => 'Register', 'url' => ['/user/regist/signup'], 'visible' => Yii::$app->user->isGuest]

//Current user
$user = Yii::$app->user->identity;
print_r($user->profile->resultInfo);
//if use $user->profile->resultData in result = base user data

//another user
$user = \anda\user\models\User::findOne(2);
print_r($user->profile->resultInfo);
//if use $user->profile->resultData in result = base user data