{"record":{"id":"8214d0fabd524621","repo":"symfony/routing","slug":"the-router-does-not-support-the-following-options-s","errorCode":null,"errorMessage":"The Router does not support the following options: \"%s\".","messagePattern":"The Router does not support the following options: \"(.+?)\"\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Router.php","lineNumber":108,"sourceCode":"            'generator_dumper_class' => CompiledUrlGeneratorDumper::class,\n            'matcher_class' => CompiledUrlMatcher::class,\n            'matcher_dumper_class' => CompiledUrlMatcherDumper::class,\n            'resource_type' => null,\n            'strict_requirements' => true,\n        ];\n\n        // check option names and live merge, if errors are encountered Exception will be thrown\n        $invalid = [];\n        foreach ($options as $key => $value) {\n            if (\\array_key_exists($key, $this->options)) {\n                $this->options[$key] = $value;\n            } else {\n                $invalid[] = $key;\n            }\n        }\n\n        if ($invalid) {\n            throw new \\InvalidArgumentException(\\sprintf('The Router does not support the following options: \"%s\".', implode('\", \"', $invalid)));\n        }\n    }\n\n    /**\n     * Sets an option.\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function setOption(string $key, mixed $value): void\n    {\n        if (!\\array_key_exists($key, $this->options)) {\n            throw new \\InvalidArgumentException(\\sprintf('The Router does not support the \"%s\" option.', $key));\n        }\n\n        $this->options[$key] = $value;\n    }\n\n    /**","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/symfony/routing/blob/83fa223250b50f4f018c011e101c330e65ac63cc/Router.php#L90-L126","documentation":"Router::setOptions() validates each option key against the set the Router supports (e.g. cache_dir, debug, resource_type, matcher...). Unknown keys are collected and, if any exist, an InvalidArgumentException listing them is thrown, typically from __construct(['bad_option' => ...]) or setOptions().","triggerScenarios":"new Router($container, $resource, ['cacheDdir' => $dir]) (typo), or passing framework-bundle-specific options (like 'cache_dir' misspelled, or options belonging to a different router class) to Symfony's Router.","commonSituations":"Typos in option names in the router service configuration; copying options from another routing library; upgrading Symfony where an option was renamed or removed.","solutions":["Fix the option key spelling against Router::setOptions/available options (cache_dir, debug, generator_class, matcher_class, matcher_base_class, matcher_dumper_class, matcher_cache_class, generator_base_class, generator_dumper_class, generator_cache_class, resource_type).","Remove unsupported options; they may belong to a different router implementation (e.g. FrameworkBundle's router).","Check the exception message — it lists exactly which keys are invalid.","If the option existed in an older Symfony version, consult the UPGRADE notes for the renamed replacement."],"exampleFix":"// before\n$router = new Router($container, 'routes.yaml', ['cacheDdir' => '/tmp/cache']);\n\n// after\n$router = new Router($container, 'routes.yaml', ['cache_dir' => '/tmp/cache']);","handlingStrategy":"validation","validationCode":"$supported = ['cache_dir','debug','resource_type','matcher_class','matcher_base_class','matcher_dumper_class','matcher_cache_class','generator_class','generator_base_class','generator_dumper_class','generator_cache_class'];\n$invalid = array_diff(array_keys($options), $supported);\nif ($invalid) {\n    throw new \\InvalidArgumentException('Unsupported router options: '.implode(', ', $invalid));\n}","typeGuard":null,"tryCatchPattern":"try {\n    $router = new Router($container, $resource, $options);\n} catch (\\InvalidArgumentException $e) {\n    // inspect message for the listed invalid keys and fix config\n}","preventionTips":["Copy option names from the Router class source or IDE autocomplete, never by hand from memory.","Centralize router option construction in one factory method with a whitelist.","When upgrading Symfony, diff option names against the UPGRADE notes."],"tags":["symfony","routing","configuration","invalid-option"],"backgroundTag":"unsupported-config-value","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"}