{"record":{"id":"3596a668270aeb5b","repo":"symfony/routing","slug":"unable-to-use-expressions-as-the-symfony-expressionlanguage-3596a6","errorCode":null,"errorMessage":"Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running \"composer require symfony/expression-language\".","messagePattern":"Unable to use expressions as the Symfony ExpressionLanguage component is not installed\\. Try running \"composer require symfony/expression-language\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Matcher/UrlMatcher.php","lineNumber":248,"sourceCode":"    /**\n     * Get merged default parameters.\n     */\n    protected function mergeDefaults(array $params, array $defaults): array\n    {\n        foreach ($params as $key => $value) {\n            if (!\\is_int($key) && null !== $value) {\n                $defaults[$key] = $value;\n            }\n        }\n\n        return $defaults;\n    }\n\n    protected function getExpressionLanguage(): ExpressionLanguage\n    {\n        if (!isset($this->expressionLanguage)) {\n            if (!class_exists(ExpressionLanguage::class)) {\n                throw new \\LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running \"composer require symfony/expression-language\".');\n            }\n            $this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);\n        }\n\n        return $this->expressionLanguage;\n    }\n\n    /**\n     * @internal\n     */\n    protected function createRequest(string $pathinfo): ?Request\n    {\n        if (!class_exists(Request::class)) {\n            return null;\n        }\n\n        return Request::create($this->context->getScheme().'://'.$this->context->getHost().$this->context->getBaseUrl().$pathinfo, $this->context->getMethod(), $this->context->getParameters(), [], [], [\n            'SCRIPT_FILENAME' => $this->context->getBaseUrl(),","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Matcher/UrlMatcher.php#L230-L266","documentation":"UrlMatcher::getExpressionLanguage() evaluates route condition expressions at match time; it throws this LogicException when the symfony/expression-language class is not installed. Triggered by handleRouteRequirements when a matched route has a condition expression.","triggerScenarios":"A matched route defines condition: \"...\" (expression) and the request is matched at runtime while symfony/expression-language is not in vendor/ — e.g. non-optimized (dev) routing without the component.","commonSituations":"Adding condition: to routes.yaml in a project that never required expression-language; environments where composer installed a subset of packages.","solutions":["Run composer require symfony/expression-language","Remove the condition: expression from the route","Replace the condition with a request listener that throws NotFoundHttpException as needed"],"exampleFix":"// shell\ncomposer require symfony/expression-language","handlingStrategy":"fallback","validationCode":"foreach ($routes->all() as $name => $r) { if ($r->getCondition() && !class_exists(\\Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::class)) { trigger_error(\"Route $name needs symfony/expression-language\", E_USER_WARNING); } }","typeGuard":"function canEvaluateConditions(): bool { return class_exists(\\Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::class); }","tryCatchPattern":"try { $params = $matcher->match($path); } catch (\\LogicException $e) { if (str_contains($e->getMessage(), 'ExpressionLanguage component is not installed')) { /* install component or strip conditions */ } throw $e; }","preventionTips":["Install symfony/expression-language if any route has a condition:","Audit route definitions for 'condition:' before pruning dependencies","Prefer explicit listeners over runtime expressions when the component is unwanted"],"tags":["routing","missing-dependency","expression-language","symfony"],"backgroundTag":"missing-optional-dependency","analyzedSha":"83fa223250b50f4f018c011e101c330e65ac63cc","analyzedAt":"2026-09-14T03:19:46.280Z","contentChangedAt":"2026-09-14T03:19:46.280Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}