I'm trying to install and configure yii2-user module to my yii2 basic application. But it is not working:
First added this to composer.json file:
"dektrium/yii2-user": "*"
and updated composer. Then just added this code inside $config not inside components section in config/web.php file:
'modules' => [
'user' => [
'class' => 'dektrium\user\Module',
],
],
Then added this to layouts/main.php :
$navItems=[
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'Status', 'url' => ['/status/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']]
];
if (Yii::$app->user->isGuest) {
array_push($navItems,['label' => 'Sign In', 'url' => ['/user/login']],['label' => 'Sign Up', 'url' => ['/user/register']]);
} else {
array_push($navItems,['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']]
);
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $navItems,
]);
And I have two more menu buttons: "Sign in" and "Sign up" Then when I try to enter this url:
mysite/index.php?r=user%2Fregistration%2Fregister
It comes:
Class 'yii\web\AccessControl' not found
in vendor/dektrium/yii2-user/controllers/RegistrationController.php at line 34
or when I hit Sign in button in my app, it comes Page not found file
I include
yii\filters\AccessControl
class
instead of
yii\web\AccessControl
class
And it worked for me