I am setting up routing that allows the following routing:
/client_a/dashboard/
/client_b/dashboard/
I am using a prefix in my app/config/routing.yml that looks like this:
AcmeMainBundle:
resource: "@AcmeMainBundle/Resources/config/routing.yml"
prefix: /{client}
The problem I am running into is that the login routing seems to be having issues with the prefix. Here is my entries in the /Resources/config/routing.yml I am importing into the main routing file:
acme_login:
pattern: /login/
defaults: {_controller: AcmeMainBundle:Main:login }
acme_login_check:
pattern: /login_check
# defaults: This is not required since the Firewall will handle this
acme_logout:
pattern: /logout/
# defaults: This is not required since the Firewall will handle this
The login page displays fine, but after the user submits the login page, Symfony throws an error stating:
Unable to find the controller for path "/client_a/login_check". Maybe you forgot to add the matching route in your routing configuration?
It looks to me that Symfony2 is having difficulties with the internal security routing and using a prefix in routing.yml.
Any way to overcome the issue?
NOTE: One way to get around this issue is by changing all the routes in my routing.yml file to include the {client} parameter. The only problem is that this is a very extensive app with a large number of routes. Using the prefix works wonders, except for the security processing during login.
Thanks,
JB
After quite some research and trying different aspects, there seems to be no good solution at this point using dynamic prefixes in the routing.
The issue seems to be that the security bundle executes its code before the routing happens, so the routing attributes from the prefix are not available in security.yml, but are rather static paths. This in itself is causing issues, as Symfony then complains about missing attributes and the likes.
So, the answer is, that in conjunction with a security implementation, the above is not possible, at least not in a way that I found.