【发布时间】:2015-10-17 17:27:33
【问题描述】:
我正在尝试将用户管理模块安装到 Yii2 应用程序(供参考,即模块:https://github.com/webvimark/user-management)。
假设我不知道作曲家是什么,但我安装了它并设法使它适用于安装。我正在运行本地服务器,因为应用程序位于我无法访问 SSH 终端的共享主机上。
我进行了 README 文件中指定的所有更改并运行了composer require --prefer-dist webvimark/module-user-management "*"。它发挥了作用,就我所见,它在应用程序的供应商文件夹中生成了一堆目录。我将它们上传到服务器,但现在当我尝试加载主页时,出现错误:
类 webvimark\modules\UserManagement\components\UserConfig 没有 存在
文件目前在这里:
APPLICATION_HOME\public_html\basic\vendor\webvimark\module-user-management\components
但应用程序似乎无法找到它。我没有模块目录(就像以前的 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;
【问题讨论】:
-
给我看看你的confi/main.php
-
config/main.php 是 Yii2.0 之前的老派,但我已经编辑了问题并添加了 config/web.php。希望这会给你一个提示
标签: php yii2 yii-components