Closed
Description
Symfony version(s) affected: 3.2 - master
Description
Using env vars in routing configuration is not supported and actively denied:
symfony/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
Lines 163 to 165 in e3927b6
However, if we use indirection with a parameter we can avoid this error, but routing will not work as expected.
How to reproduce
This will be denied correctly, as described above:
# config.yaml
parameters:
env(route_prefix): 'default'
# routes.yaml
some_route:
path: /%env(route_prefix)%/contact
controller: App\Controller\MainController::contact
However, this will not throw an error:
# config.yaml
parameters:
env(route_prefix): 'default'
route_prefix: '%env(route_prefix)%'
# routes.yaml
some_route:
path: /%route_prefix%/contact
controller: App\Controller\MainController::contact
This will allow the container to boot, but defining a different route_prefix
env var will never have any effect.
Possible Solution
For good and non confusing DX, detect if parameters are pointing to env vars and deny building routes up front.