{"record":{"id":"7d7a88c90eb5df53","repo":"symfony/routing","slug":"the-router-s-cannot-be-warmed-up-because-it-does-not","errorCode":null,"errorMessage":"The router \"%s\" cannot be warmed up because it does not implement \"%s\".","messagePattern":"The router \"(.+?)\" cannot be warmed up because it does not implement \"(.+?)\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"CacheWarmer/RouterCacheWarmer.php","lineNumber":49,"sourceCode":"     */\n    public function __construct(\n        private ContainerInterface $container,\n    ) {\n    }\n\n    public function warmUp(string $cacheDir, ?string $buildDir = null): array\n    {\n        if (!$buildDir) {\n            return [];\n        }\n\n        $router = $this->container->get('router');\n\n        if ($router instanceof WarmableInterface) {\n            return $router->warmUp($cacheDir, $buildDir);\n        }\n\n        throw new \\LogicException(\\sprintf('The router \"%s\" cannot be warmed up because it does not implement \"%s\".', get_debug_type($router), WarmableInterface::class));\n    }\n\n    public function isOptional(): bool\n    {\n        return true;\n    }\n\n    public static function getSubscribedServices(): array\n    {\n        return [\n            'router' => RouterInterface::class,\n        ];\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":64,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/CacheWarmer/RouterCacheWarmer.php#L31-L64","documentation":"RouterCacheWarmer::warmUp() fetches the 'router' service and, if it does not implement WarmableInterface, cannot be warmed and throws a LogicException. The warmer assumes the container's router supports cache warming.","triggerScenarios":"A custom router service registered under the 'router' id that doesn't implement Symfony\\Component\\HttpKernel\\CacheWarmer\\WarmableInterface, then running cache:warmup or building the prod cache.","commonSituations":"Replacing the default router with a custom implementation or decorator that forgets to implement WarmableInterface; upgrading Symfony where warmer expectations tightened.","solutions":["Make the custom router class implement WarmableInterface (with the warmUp(string $cacheDir, ?string $buildDir) signature)","Return the decorated inner router from the wrapper so instanceof check passes","Make the router service optional/aliased correctly so the default Router is used"],"exampleFix":"// before\nclass MyRouter implements RouterInterface { /* ... */ }\n// after\nclass MyRouter implements RouterInterface, WarmableInterface {\n    public function warmUp(string $cacheDir, ?string $buildDir = null): array { return []; }\n}","handlingStrategy":"type-guard","validationCode":"$router = $container->get('router');\nif (!$router instanceof WarmableInterface) {\n    throw new \\LogicException('Router must implement WarmableInterface for cache warming');\n}","typeGuard":"if ($router instanceof \\Symfony\\Component\\HttpKernel\\CacheWarmer\\WarmableInterface) {\n    $router->warmUp($cacheDir, $buildDir);\n}","tryCatchPattern":"try {\n    (new RouterCacheWarmer($container))->warmUp($cacheDir, $buildDir);\n} catch (\\LogicException $e) {\n    // fall back to skipping router warming or fix the router service\n}","preventionTips":["Any custom router service must implement WarmableInterface","Add an interface check test for the 'router' service","Prefer decorating the core Router (which is warmable) over replacing it"],"tags":["php","routing","cache-warming","symfony-kernel"],"backgroundTag":"missing-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"}