简体   繁体   中英

Controller mapping causing error in yii2 console application

Module section config

'user'  => [
            'class' => 'dektrium\user\Module',
            'modelMap' => [
                'User' => 'app\models\DL\User',
                'registrationForm' => 'app\models\DL\registrationForm',
            ],
            'controllerMap' => [
                /*'registration' =>    'app\controllers\user\RegistrationController',
                'admin' => 'app\controllers\user\AdminController'*/
            ],
            'layout'       => '@app/views/layouts/container',
            'defaultRoute' => 'profile',
            'admins'       => ['admin'],
            'enableFlashMessages' => false,
            'params' => [
                'menuItems'      => [
                    'label' => 'Users',
                    'url'   => ['/user/admin']
                ]
            ]
        ],

Yii console application (./yii) showing me error

'Calling unknown method: app\\controllers\\user\\AdminController::getHelpSummary()'

If I uncomment the controllerMap section, I can't understand why it autoloads in console app if my AdminController extends web controller not console.

This is commands from user module.

这是来自用户模块的命令

Do you really need the user module in console?

Yii2 console and web applications have separated configuration files by default. If you changed this default and use the same config for both of them, you must take care about consistency.

You can check the list of loaded configs in ./yii .

You need to specify a valid defaultRoute for the console application.

With 'defaultRoute' => 'profile' , ./yii may try to load a Controller which requires the user module.

Try adding it in the console configuration .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM