I don't get the difference between Dynamic Router and Chain Router in Symfony2 CMF. I could see that there is a difference in syntax, but I don't get concept.
Can someone tell me the difference conceptually?
The ChainRouter is used to chain multiple routers. If router1 can't match a route to the current path, it'll go to router2 and checks if that one can match the route. If nothing matches, it'll throw an 404 not found exception.
Please note that the ChainRouter isn't capable of matching routes. It must have routers which do that.
The DynamicRouter is a router. It matches paths to routes. Instead of the Symfony2 Router, it's dynamic. It'll use RouteProvider to get the routes and match them against the path.
Chain Routing:
Chain routing is a concept in which you can use more then 1 routing method i.e (a default symfony routing or a dynamic routing ).Using chain routing we can specify which of routing method to be prioritize on the basis of which the symfony router works.
for eg. Let's take a example that if we provide higher priority to dynamic routing then the symfony default routing then in the beginning the symfony routing finds for dynamic route if that is not found then only it tries for the default routing mechanism.This is how chain routing works In gist chain routing helps to use more then one routing mechanisms with a provided priority. as shown below is config.yml which shows the priority of two routing mechanism: //config.yml
cmf_routing:
chain:
routers_by_id:
router.default: 200
cmf_routing.dynamic_router: 100
Priority can be set in similar way.The higher the no the higher will be the priority
Dynamic Routing: Dynamic Routing loads Route instances from a dynamic source via a so called provider(may be a database or services). However the DynamicRouter additionally is able to determine which Controller and Template to use based on the Route that is matched.
if you are interested in learning more: http://symfony.com/doc/current/cmf/book/routing.html