1. Go to this page and download the library: Download filsh/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/ */
filsh / yii2-user example snippets
// app/config/web.php
return [
'components' => [
'user' => [
'class' => 'filsh\yii2\user\components\User',
],
'mail' => [
// set up mail for emails
]
],
'modules' => [
'user' => [
'class' => 'filsh\yii2\user\Module',
// set custom module properties here ...
],
],
];
// app/config/db.php
return [
'class' => 'yii\db\Connection',
// set up db info
];
if (!Yii::$app->user->can("admin")) {
throw new HttpException(403, 'You are not allowed to perform this action.');
}
// --- or ----
$user = User::findOne(1);
$user->can("admin");