I have all the following GET routes defined in my_module.routing.yml:

  path: 'users/{user}'

  path: 'users/{user}/group/{group}'

  path: 'users/{uid}/{bundle}/{gid}'

All of these have the same requirements and options except they upcast different data types, and each has it's own controller.

All of my controllers execute correctly, however is there any benefit to a particular order? Or is there any extra overhead from two matching except one dynamic parameter?


The order doesn't matter, routes are stored indexed by name. The first and the second route have a different component count, so they can't interfere. The second route gets priority over the third, because it has one more fixed component. So in this case the route matching doesn't need any complex calculations. In general route matching rarely affects performance because successful matches are cached.

  • ok @4k4. i trust that's still the case when there's 4/5 more URL matches for their different _auth _json, method settings? – E.A.T Oct 4 '19 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.