Problem extending console MessageController

I have some functionality, that I want to add to yii\console\controllers\MessageController::actionExtract().

So normally what I have done - extended Yii controller with my own controller and placed it to app\commands directory.


namespace app\commands;

class MessageController extends \yii\console\controllers\MessageController{ /* .. */ }

For test purposes I added method named actionTest.

When I do > yii command, all I get is parent class actions listed.

Now I copy-pasted exactly same controller and just renamed it to MsgController. Previous controller left intact.

So now > yii gives me parent class actions plus my newly added actionTest

> yii message/test - ‘Unknown command message/test’

> yii msg/test - ‘OK’

My app\config\console.php has

'controllerNamespace' => 'app\commands'

How should I properly extend MessageController and continue use standard Yii command (means not changing controller name to have new command)?

You need to adjust configuration to use your command instead of built-in one.

'controllerMap' => [

    'message' => [

        'class' => 'app\commands\MessageController',