PHP code example of qingbing / yii2-backend-user

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

    

qingbing / yii2-backend-user example snippets


'controllerMap' => [
    // 后管用户系统
    'login'    => \YiiBackendUser\controllers\LoginController::class,
    'personal' => \YiiBackendUser\controllers\PersonalController::class,
]

'components' => [
    'user'           => [
        'class'           => \YiiBackendUser\components\User::class,
        'identityClass'   => \YiiBackendUser\models\User::class,
        'enableAutoLogin' => true,
        'identityCookie'  => ['name' => '_identity-' . define_var('CONF_APP_ID', 'portal'), 'httpOnly' => true],
        'multiUserLogin'      => define_var('COM_USER_MULTI_USER_LOGIN', false), // 允许用户多客户端登录
        'multiAccountLogin'      => define_var('COM_USER_MULTI_ACCOUNT_LOGIN', false), // 允许账户多客户端登录
        // 允许登录的账户类型
        'loginTypes'      => [
            \YiiBackendUser\models\UserAccount::TYPE_EMAIL,
            \YiiBackendUser\models\UserAccount::TYPE_USERNAME,
            \YiiBackendUser\models\UserAccount::TYPE_MOBILE,
            \YiiBackendUser\models\UserAccount::TYPE_NAME,
        ],
    ],
],

'bootstrap'     => [
    'bootPermission',
],
'components' => [
    'bootPermission' => [
        'class'      => \YiiBackendUser\boots\PermissionBootstrap::class,
        'openCheck'  => define_var('COM_BOOT_PERMISSION_OPEN_CHECK', true), // 是否开启权限检查
        'pubPaths'   => [
            'portal/inner/*', // inner模块接口属于内部服务调用接口,模块内部
            'portal/login/*', // 登录及检查
            'portal/test/*',
            'portal/login/*',
            'portal/public/*'
        ],
        'whiteIps'   => [
            '192.168.1.1',
        ],
        'whitePaths' => [
        ],
    ],
],

// user 组件配置
defined('COM_USER_MULTI_USER_LOGIN') or define('COM_USER_MULTI_USER_LOGIN', true); // 允许用户多终端登录
defined('COM_USER_MULTI_ACCOUNT_LOGIN') or define('COM_USER_MULTI_ACCOUNT_LOGIN', true); // 允许账号多终端登录

// bootPermission 组件
defined('COM_BOOT_PERMISSION_OPEN_CHECK') or define('COM_BOOT_PERMISSION_OPEN_CHECK', true); // 是否开启权限检查