You can use parameters from parameters.yml
in routes. There are serveral use-cases when this may be useful.
Let’s say you want to localize your routes but you want to store the list of available locales only once. Then you could define a parameter in config.yml
:
parameters: allowed_locales: en|de|fr
Now you can use the parameter in your routing.yml
:
some_bundle: resource: "@MyBundle/Controller/" prefix: /{_locale} type: annotation requirements: _locale: %allowed_locales%
Another use-case is routes based on a hostname. Instead of writing the hostname directly into routing.yml
you could use a parameter, as seen in the official documentation.
As fas as I know parameters only work for routes defined in YAML, XML or PHP. If it also works for annotation routes, please let me know.