{"record":{"id":"693493379ad4bd2e","repo":"symfony/routing","slug":"unable-to-use-expressions-as-the-symfony-expressionlanguage","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/Dumper/CompiledUrlMatcherDumper.php","lineNumber":452,"sourceCode":"            $condition = null;\n        }\n\n        return [\n            ['_route' => $name] + $defaults,\n            $vars,\n            array_flip($route->getMethods()) ?: null,\n            array_flip($route->getSchemes()) ?: null,\n            $hasTrailingSlash,\n            $hasTrailingVar,\n            $condition,\n        ];\n    }\n\n    private 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    private function indent(string $code, int $level = 1): string\n    {\n        return preg_replace('/^./m', str_repeat('    ', $level).'$0', $code);\n    }\n\n    /**\n     * @internal\n     */\n    public static function export(mixed $value): string\n    {\n        if (null === $value) {","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Matcher/Dumper/CompiledUrlMatcherDumper.php#L434-L470","documentation":"CompiledUrlMatcherDumper::getExpressionLanguage() compiles route conditions written as expressions (condition: \"request... \"). It throws this LogicException when the symfony/expression-language package is not installed. The compiled matcher requires the component at dump time, not just at runtime.","triggerScenarios":"Any route has a condition: key using an expression (e.g. \"context.getMethod() in ['POST']\") while compiling/optimizing routes for a CompiledUrlMatcher and symfony/expression-language is absent from vendor/.","commonSituations":"Deploying without composer require symfony/expression-language after adding a condition to a route; production builds pruning dev dependencies that pulled the component transitively.","solutions":["Run composer require symfony/expression-language","Remove the condition: from the route if the expression is not actually needed","Move the gating logic into the controller or a kernel listener instead of a route expression"],"exampleFix":"// shell\ncomposer require symfony/expression-language","handlingStrategy":"fallback","validationCode":"if (str_contains($routeContent, 'condition:') && !class_exists(\\Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::class)) { /* install component or drop conditions */ }","typeGuard":"function expressionLanguageAvailable(): bool { return class_exists(\\Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::class); }","tryCatchPattern":"try { $routes = $dumper->dump(); } catch (\\LogicException $e) { if (str_contains($e->getMessage(), 'ExpressionLanguage component is not installed')) { /* suggest composer require */ } throw $e; }","preventionTips":["composer require symfony/expression-language whenever any route uses condition:","Verify the package survives composer install --no-dev in production builds","Keep route expressions listed/documented so dependency audits catch them"],"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"}