PHP code example of mihaildev / yii2-user
1. Go to this page and download the library: Download mihaildev/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/ */
mihaildev / yii2-user example snippets
'components' => [
'user' => [
'class' => 'mihaildev\user\Component',
'enableAutoLogin' => true,
'loginUrl' => ['/site/login'], //'loginUrl' => ['/user/login'],
'userList' => [
'1' => [// id value
'id' => '1',
'username' => 'admin',
'password' => 'admin',
]
],
'authKeySalt' => 'SomeSecreteValue'
],
class SiteController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
public function actions()
{
return [
'login' => [
'class' => 'mihaildev\user\action\LogIn',
//'template' => 'login' // default: @mihaildev/user/views/login.php,
//'defaultUrl' => ['/site/index'],
],
'logout' => 'mihaildev\user\action\LogOut',
];
}
'controllerMap' => [
'user' => [
'class' => 'mihaildev\user\Controller',
//'template' => 'login' // default: @mihaildev/user/views/login.php,
//'defaultUrl' => ['/site/index'],
]