0
votes

I'm trying to install the user-management module to Yii2 application (for reference, that's the module: https://github.com/webvimark/user-management).

Let's just say I have no idea what composer is but I installed it and managed to make it work for the installation. I'm running an a local server as the application is on a shared-hosting where I don't have access to the SSH terminal.

I made all the changes specified in the README file and I ran composer require --prefer-dist webvimark/module-user-management "*". It did its magic and for all I saw, it generated a bunch of directories in the vendor folder of the application. I uploaded them to the server but now when I try to load even the home page, I get an error:

Class webvimark\modules\UserManagement\components\UserConfig does not exist

The file is currently here:

APPLICATION_HOME\public_html\basic\vendor\webvimark\module-user-management\components

but it seems that the application is unable to find it. I have no modules directory (as I used to in previous versions of Yii) and all my config and other files are updated as specified in the readme file. Any ideas what went wrong?

EDIT: Just in case, adding my 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
Show me you confi/main.php - ScaisEdge
config/main.php is old school pre-Yii2.0, but I've edited the question and added the config/web.php. Hopefully that would give you a hint - mmvsbg

1 Answers

0
votes

try using this like a module and not a component remove from component and add in modules

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