English spoken conference
WARNING: You are browsing the documentation for version 1.0 which is not maintained anymore. If some of your projects are still using this version, consider upgrading.


1.0 version
Maintained Unmaintained


The Symfony CMF Routing component extends the Symfony2 core routing component to allow more flexibility. The most important difference is that the CMF Routing component can load routing information from a database.


This chapter provides background information on the Symfony CMF routing implementation. If you simply want to use routing in the CMF, read the RoutingBundle. If you want to customize how the routing works, please read on in this chapter.

Like the Symfony2 routing component, the CMF routing component does not require the full Symfony2 Framework and can be used in standalone projects as well.

At the core of the Symfony CMF Routing component is the ChainRouter. The ChainRouter tries to match a request with each of its registered routers, ignoring the ResourceNotFoundException until all routers got a chance to match. The first match wins - if no router matched, the ResourceNotFoundException is thrown. The default Symfony2 router can be added to this chain, so the standard routing mechanism can still be used in addition to any custom routing.

Additionally, this component provides the DynamicRouter. This router is more configurable and flexible than the Symfony2 core router. It can be configured to load routes from a database, dynamically add information to the routes and also generate URLs from model classes.

The goal of Routing

Routing is the task of a framework to determine, based on the web request, what code it has to call and which parameters to apply. The Symfony2 core RequestMatcherInterface defines that a router must convert a Request into an array of routing information. In the full stack Symfony2 framework, the code to call is defined in the _controller field of the match parameters. The framework is going to call the controller specified, matching eventual parameters of that method by name with the other parameters found in the match array or in the Request object attributes field.


For a good introduction to routing in the Symfony2 framework, please read the Routing chapter of the Symfony2 book.

To use this component outside of the Symfony2 framework context, have a look at the core Symfony2 Routing Component to get a fundamental understanding of the component. The CMF Routing Component just extends the basic behaviour.


You can install the component in 2 different ways:

Symfony2 integration

As mentioned before, this component was designed to use independently of the Symfony2 framework. However, if you wish to use it as part of your Symfony CMF project, an integration bundle is also available. Read more about the RoutingBundle in RoutingBundle in the bundles documentation.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.