yiisoft/yii2 · error · yii\console\Exception

Could not load required service: {name}

Error message

Could not load required service: {name}

What it means

Error "Could not load required service: {name}" thrown in yiisoft/yii2.

Source

Thrown at framework/console/Controller.php:257

                    } else {
                        $isArray = $param->isArray();
                    }
                    if ($isArray) {
                        $params[$key] = $params[$key] === '' ? [] : preg_split('/\s*,\s*/', $params[$key]);
                    }
                    $args[] = $actionParams[$key] = $params[$key];
                    unset($params[$key]);
                }
            } elseif (
                PHP_VERSION_ID >= 70100
                && ($type = $param->getType()) !== null
                && $type instanceof \ReflectionNamedType
                && !$type->isBuiltin()
            ) {
                try {
                    $this->bindInjectedParams($type, $name, $args, $requestedParams);
                } catch (\yii\base\Exception $e) {
                    throw new Exception($e->getMessage());
                }
            } elseif ($param->isDefaultValueAvailable()) {
                $args[] = $actionParams[$i] = $param->getDefaultValue();
            } else {
                $missing[] = $name;
            }
        }

        if (!empty($missing)) {
            throw new Exception(Yii::t('yii', 'Missing required arguments: {params}', ['params' => implode(', ', $missing)]));
        }

        // We use a different array here, specifically one that doesn't contain service instances but descriptions instead.
        if (\Yii::$app->requestedParams === null) {
            \Yii::$app->requestedParams = array_merge($actionParams, $requestedParams);
        }

        return array_merge($args, $params);

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/console/Controller.php:257 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/fcae6e55ec6da250. Report an issue: GitHub.