【问题标题】:Installing user-management for Yii2.0Yii2.0 安装用户管理
【发布时间】:2015-12-02 00:34:20
【问题描述】:

我一直在尝试为 Yii2.0 安装 user-management,但在加载页面时遇到了 ReflectionException。我在下面附上了错误页面和目录结构。

文件路径如下图。

我已经搜索了很多以找出原因,但没有任何结果。有人能告诉我我在这里缺少什么来让它工作吗?看起来user-management installation documentation 有一些缺陷。理解的不够清楚。希望得到安装步骤。谢谢

这是我的控制台/web.php

    <?php

$params = require(__DIR__ . '/params.php');

$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
    'request' => [
        // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
        'cookieValidationKey' => 'gAry7SfUr0oOjNQDqItsobmGBcJajQoW',
    ],
    'cache' => [
        'class' => 'yii\caching\FileCache',
    ],
    'user' => [
        //'identityClass' => 'app\models\User',
        'enableAutoLogin' => true,
        'class' => 'app\webvimark\modules\user-management\components\UserConfig',

    // Comment this if you don't want to record user logins
    'on afterLogin' => function($event) {
            \webvimark\modules\user-management\models\UserVisitLog::newVisitor($event->identity->id);
        }
    ],
    'errorHandler' => [
        'errorAction' => 'site/error',
    ],
    'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        // send all mails to a file by default. You have to set
        // 'useFileTransport' to false and configure a transport
        // for the mailer to send real emails.
        'useFileTransport' => true,
    ],
    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
            ],
        ],
    ],
    'db' => require(__DIR__ . '/db.php'),
],

'modules'=>[
'user-management' => [
    'class' => 'webvimark\modules\user-management\UserManagementModule',

    // 'enableRegistration' => true,

    // Here you can set your handler to change layout for any controller or action
    // Tip: you can use this event in any module
    'on beforeAction'=>function(yii\base\ActionEvent $event) {
            if ( $event->action->uniqueId == 'user-management/auth/login' )
            {
                $event->action->controller->layout = 'loginLayout.php';
            };
        },
    ],
],
'params' => $params,
];

if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
    'class' => 'yii\debug\Module',
];

$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
    'class' => 'yii\gii\Module',
];
}

return $config;

【问题讨论】:

  • 您使用的是基本模板还是高级模板?
  • 我使用基本模板
  • 你可以从给定图像中的 url 观察到它
  • 请显示您的 config/web.php 代码
  • web.php 已添加

标签: installation yii2 user-management


【解决方案1】:

似乎与此扩展的预期配置略有不同。

使用这个

'class' => 'webvimark\modules\UserManagement\components\UserConfig',

UserManagement 而不是user-management 是配置路径而不是路由

【讨论】:

  • 是的,我已经更改了它,但我仍然得到相同的异常
  • 你确定你也用 UserManagement 改变了用户管理模块吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-08
  • 2015-10-17
  • 1970-01-01
  • 1970-01-01
  • 2017-05-27
  • 1970-01-01
相关资源
最近更新 更多