I've a Symfony 4 app that is running fine until I want to define a route with the _locale
parameter.
I define two routes for the same action with the following code :
/**
* @Route("/sites/{id}",
* name="site_get",
* methods={"GET"},
* requirements={"id": "\d+"},
* )
* @Route("/{_locale}/sites/{id}",
* name="site_get_with_locale",
* methods={"GET"},
* requirements={"id": "\d+"},
* )
*/
When I call the url /sites/1
I get the resource but if I call /en/sites/1
I get a 404 error "route not found".
Here are the things I've tried :
- tried to change
/{_locale}/sites/{id}
with/{locale}/sites/{id}
and the route is working but, obviously, the locale is not changed. - tried to set requirements for the
_locale
parameter but it is no better - tried to set the
{_locale}
parameter as a prefix (in annotations.yaml) with no luck neither - I can see the route definition in the debug:router :
site_get.0 GET ANY ANY /api/sites/{id}
site_get_with_locale.0 GET ANY ANY /api/{_locale}/sites/{id}
Edit 1 :
In the profiler for the given failed request /en/sites/1
:
- the configuration sections shows me thet the Intl locale is fr.
- In the routing section I don't see the same at in the debug:router command :
{_locale}
is changed into0
(even if I set requirement for the _locale tofr|en
)
Edit 2 : I was using Symfony 4.4.8 but downgrading to 4.4.7 seems to work. I also have the problem with 4.4.10
Any idea of another path to explore?
Thank you,
Vincent