Search code examples
symfonysymfony-routing

Route names starting with underscore in Symfony2


I'm working on a Symfony2 project and in the file routing.yml I have the following lines:

_front:
    resource: routing_front.yml

_admin:
    resource: routing_admin.yml
    prefix:   /admin

So this actually allows defining the routes for the front-end and the back-end in separate dedicated files.

What about the names though ? Is it simply a naming convention to start with an underscore - which will tell at first sight that the actual routes are in a different file - or has this an influence on how the framework handle those ?


Solution

  • It's only a naming convention.

    But the Framework will handle the routes by matching the first route defined with the matching url requested, then the second one and so on...

    So in your case, even if you requested http://www.mysyte.com/admin/whatever, it will match this url with all the routes in routing_front.yml before matching them with routing_admin.yml