In the configuration file of the console
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'controllerMap' => [
'init-auth' => [
'class' => InitAuthController::class,
'adminClass' => 'common\models\Admin',
'superAdminId' => 1,
'superAdminRoleId' => 1,
'authRoleAttribute' => 'auth_role',
'authClass' => 'common\models\base\Auth',
'initRoles' => [
['超级管理员', '拥有所有权限', ['all'], 1],
],
],
'auth-generator' => [
'class' => AuthGeneratorController::class,
'genClass' => 'common\models\base\Auth',
'configFile' => '@common/models/base/auth-config.php',
],
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationPath' => [
'@console/migrations',
'@console/migrations/2016',
'@console/migrations/2017',
'@console/migrations/2018',
'@console/migrations/2019',
],
],
'queue'=>[
'class'=>\yii\queue\redis\Command::class,
'queue' => new \yii\queue\redis\Queue([
'redis' => $redisConfig// redis的配置
])
],
],
];
In fact, from the execution of the queue command, we know that it must be the command yii queue/listen, and enter
yii\queue\redis\Command looks at it and it is indeed an inherited controller, so we write it in controllerMap. (Some things involving bootstrap need to be sorted out carefully, so I won’t go into details here)