Symfony2 Default Routing Bundle

The LswDefaultRoutingBundle adds default routing to your Symfony2 application. Default routing adds a route naming scheme to the configured bundles. This forces consistent naming of routes and simplifies both programming and debugging. source: Github

At LeaseWeb we develop a lot of software in Symfony2 and we are proud to contribute our second Symfony2 bundle to the Symfony2 community, the¬†LswDefaultRoutingBundle. The bundle automatically adds routes to the Symfony2 routing table that behave like the default route does in Symfony 1. It allows you to configure bundles (like ‘FosUserBundle’) to automatically add the route ‘fos_user.user.login’ with url ‘/user/login’ for the ‘loginAction’ function in the ‘UserController’ class. It is inspired by hidenorigoto’s¬†DefaultRouteBundle, but it behaves somewhat different.

The bundle provides the following features:

  1. Default routing: Adds a route to the routing table for every public action you implement with name ‘{bundle}.{controller}.{action}’ and URL ‘{prefix}/{controller}/{action}’.
  2. Default templating: You do not have to specify a template for an action, behaves like the empty template annotation: @Template()
  3. Relative routing: Allows you to specify only a part of the route, while other parts are extracted from the current route. You can refer to route ‘fos_user.user.view’ from ‘fos_user.user.index’ by specifying the non-existent route ‘view’.

We use it for more than half a year now and it has become an essential part of our software. Check it out at:

You can get started by reading the readme documentation on GitHub.

We are working on open sourcing even more bundles, so stay tuned!


One thought on “Symfony2 Default Routing Bundle”

Leave a Reply

Your email address will not be published. Required fields are marked *