I want to create a route in Symfony in the following ways: /admin/_api/* and /admin/*. So, overall I want to have a configuration like the following:
/admin/_api/users
/admin/_api/posts
/admin/_api/comments
/admin/_api/* -> (AdminBundle:Error:api)
/admin/* -> (AdminBundle:Error:html)
Based on the given configuraiton, if a user goes to /admin/_api/test, the router will dispatch to ErrorController::apiAction. If a user goes to /admin/users it will dispatch to ErrorController:htmlAction.
Is there a way to achieve this?
You could try it with requirements, in routing.yml:
# All your routes that should match first.
admin_api_wildcard:
path: /admin/_api/{wildcard}
defaults: { _controller: AdminBundle:Error:api }
requirements:
wildcard: .*
Prior to (Symfony 3) it´s pattern instead of path :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With