symfony/routing · error · LogicException

The router " " cannot be warmed up because it does not…

Error message

The router "%s" cannot be warmed up because it does not implement "%s".

What it means

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.

Solutions

  1. Make the custom router class implement WarmableInterface (with the warmUp(string $cacheDir, ?string $buildDir) signature)
  2. Return the decorated inner router from the wrapper so instanceof check passes
  3. Make the router service optional/aliased correctly so the default Router is used

Example fix

// before
class MyRouter implements RouterInterface { /* ... */ }
// after
class MyRouter implements RouterInterface, WarmableInterface {
    public function warmUp(string $cacheDir, ?string $buildDir = null): array { return []; }
}
Defensive patterns

Strategy: type-guard

Validate before calling

$router = $container->get('router');
if (!$router instanceof WarmableInterface) {
    throw new \LogicException('Router must implement WarmableInterface for cache warming');
}

Type guard

if ($router instanceof \Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface) {
    $router->warmUp($cacheDir, $buildDir);
}

Try / catch

try {
    (new RouterCacheWarmer($container))->warmUp($cacheDir, $buildDir);
} catch (\LogicException $e) {
    // fall back to skipping router warming or fix the router service
}

Prevention

When it happens

Trigger: 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.

Common situations: Replacing the default router with a custom implementation or decorator that forgets to implement WarmableInterface; upgrading Symfony where warmer expectations tightened.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of symfony/routing@83fa223250 (2026-09-14). Data as JSON: /api/errors/7d7a88c90eb5df53. Report an issue: GitHub.

Appendix: source

Thrown at CacheWarmer/RouterCacheWarmer.php:49

     */
    public function __construct(
        private ContainerInterface $container,
    ) {
    }

    public function warmUp(string $cacheDir, ?string $buildDir = null): array
    {
        if (!$buildDir) {
            return [];
        }

        $router = $this->container->get('router');

        if ($router instanceof WarmableInterface) {
            return $router->warmUp($cacheDir, $buildDir);
        }

        throw new \LogicException(\sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));
    }

    public function isOptional(): bool
    {
        return true;
    }

    public static function getSubscribedServices(): array
    {
        return [
            'router' => RouterInterface::class,
        ];
    }
}

View on GitHub (pinned to 83fa223250)