2

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.

This is commands from user module

JAL
  • 41,701
  • 23
  • 172
  • 300
StalkAlex
  • 743
  • 7
  • 16

2 Answers2

0

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.

SilverFire
  • 1,582
  • 13
  • 22
  • I am using phundament template for yii2. https://github.com/phundament/app/blob/4.0.0-rc8/src/config/main.php. And problem is I am not able to use ./yii. It crashes straight away. – StalkAlex Nov 16 '15 at 16:35
  • You can remove `user` module by adding override in `$console` [config](https://github.com/phundament/app/blob/4.0.0-rc8/src/config/main.php#L205) – SilverFire Nov 16 '15 at 20:28
  • Yep, already tried it. I added screen with problem commands. If I override this module from console section, this commands will go away too. – StalkAlex Nov 17 '15 at 04:30
  • Then you need to implement methods that are required by the console application, to get it work – SilverFire Nov 17 '15 at 14:57
  • Also thought about it, even tried it, turned out it's much more than pair of methods. I wonder why there is no error when same controllers are used from vendor folder. Vendor classes also don't contain those methods. – StalkAlex Nov 17 '15 at 15:14
0

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

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

Try adding it in the console configuration.

schmunk
  • 4,708
  • 1
  • 27
  • 50
  • My console section looks the same as in the link you've provided. I am using Phundament app. Or did I misunderstood something? – StalkAlex Dec 18 '15 at 11:21
  • If it's exactly the same and your `defaultController` in `$common` is set to `profile` it also applies for the console. Try to move the `defaultController` to [`$web`](https://github.com/phundament/app/blob/3a6d8bca94d3b82dcb424930cd662f085eaa573d/src/config/main.php#L151) – schmunk Dec 18 '15 at 14:18
  • Just tried it. Same effect. Only thing that helped me is moving all `controllerMap` section to web part. – StalkAlex Dec 22 '15 at 07:11