安装Yii2用户管理模块

时间:2015-07-27 13:36:20

标签: php yii2 yii-components

我正在尝试将用户管理模块安装到Yii2应用程序(作为参考,即模块:https://github.com/webvimark/user-management)。

我们只是说我不知道​​作曲家是什么,但我安装了它并设法让它适用于安装。我正在运行本地服务器,因为应用程序位于共享主机上,我无法访问SSH终端。

我完成了README文件中指定的所有更改,并运行了composer require --prefer-dist webvimark/module-user-management "*"。它发挥了它的魔力,而且就我所见,它在应用程序的vendor文件夹中生成了一堆目录。我将它们上传到服务器但现在当我尝试加载主页时,我收到一个错误:

  

类webvimark \ modules \ UserManagement \ components \ UserConfig没有   存在

该文件目前在此处:

  

APPLICATION_HOME \的public_html \基本\供应商\ webvimark \模块用户管理\部件

但似乎应用程序无法找到它。我没有模块目录(就像以前版本的Yii中一样),我的所有配置和其他文件都按照自述文件中的指定进行更新。任何想法出了什么问题?

编辑:以防万一,添加我的config / 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' => 'SOME_RANDOM_STRING',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        /*'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],*/
        'user' => [
            'class' => 'webvimark\modules\UserManagement\components\UserConfig',

            // Comment this if you don't want to record user logins
            'on afterLogin' => function($event) {
                \webvimark\modules\UserManagement\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'),
        'i18n' => [
            'translations' => [
                'frontend*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@common/messages',
                ],
                'backend*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@common/messages',
                ],
            ],
        ],
    ],
    'modules'=>[
        'user-management' => [
            'class' => 'webvimark\modules\UserManagement\UserManagementModule',

            // 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'] = 'yii\debug\Module';

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

return $config;

1 个答案:

答案 0 :(得分:0)

尝试使用它像模块而不是组件 从组件中删除并添加模块

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