yiisoft/yii2 · error · yii\console\UnknownCommandException
Unknown command "$route".
Error message
Unknown command "$route".
What it means
Error "Unknown command "$route"." thrown in yiisoft/yii2.
Source
Thrown at framework/console/Application.php:184
* code should be used:
*
* ```
* \Yii::$app->runAction('controller/test', ['option' => 'value', $a, $b]);
* ```
*
* @param string $route the route that specifies the action.
* @param array $params the parameters to be passed to the action
* @return int|Response|null the result of the action. This can be either an exit code or Response object.
* Exit code 0 means normal, and other values mean abnormal. Exit code of `null` is treated as `0` as well.
* @throws Exception if the route is invalid
*/
public function runAction($route, $params = [])
{
try {
$res = parent::runAction($route, $params);
return is_object($res) ? $res : (int) $res;
} catch (InvalidRouteException $e) {
throw new UnknownCommandException($route, $this, 0, $e);
}
}
/**
* Returns the configuration of the built-in commands.
* @return array the configuration of the built-in commands.
*/
public function coreCommands()
{
return [
'asset' => 'yii\console\controllers\AssetController',
'cache' => 'yii\console\controllers\CacheController',
'fixture' => 'yii\console\controllers\FixtureController',
'help' => 'yii\console\controllers\HelpController',
'message' => 'yii\console\controllers\MessageController',
'migrate' => 'yii\console\controllers\MigrateController',
'serve' => 'yii\console\controllers\ServeController',
];View on GitHub (pinned to 66f00d18a2)
When it happens
Trigger: Thrown at framework/console/Application.php:184 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17).
Data as JSON: /api/errors/be1f0ef4280645c0.
Report an issue: GitHub.