yii2-user类'yii \ web \ AccessControl'未找到

时间:2016-03-20 05:28:25

标签: registration user-registration yii2-user

我正在尝试在我的yii2基本应用程序中安装和配置yii2-user模块。但它不起作用:

首先将此添加到composer.json文件中:

"dektrium/yii2-user": "*"

和更新的作曲家。然后在$ config中添加此代码而不是在config / web.php文件中的components部分:

'modules' => [
    'user' => [
        'class' => 'dektrium\user\Module',
    ],
],

然后将其添加到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,
]);

我还有两个菜单按钮:“登录”和“注册” 然后当我尝试输入这个网址时:

  

mysite的/的index.php?R =用户%2Fregistration%2Fregister

它来了:

Class 'yii\web\AccessControl' not found
in vendor/dektrium/yii2-user/controllers/RegistrationController.php at line 34

或当我在我的应用中点击登录按钮时,会出现找不到网页文件

1 个答案:

答案 0 :(得分:0)

我包括

yii\filters\AccessControl上课

而不是

yii\web\AccessControl上课

它对我有用