What is routing and how to use it in symfony

Routing in Symfony 2 is even easier than in Symfony 1.x.

Also you can prefix imported routes and give a group of routes a prepend text:

#app/config/routing.yml
    acme_hello:
    resource: “@AcmeHelloBundle/Resources/config/routing.yml”
    prefix: /admin
Working with annotations

article_show:
    pattern: /{_locale}/article-details/{page}.{_format}
    defaults: {_controller:Bundle:Controller:Action, _format: html, page:1}
    requirements:
        _locale: en|fr
        _format: html|rss
        page: \d+
        _scheme: http|https

You can use annotations in your controller by enabling annotations in your routing.yml and in your config.yml

#config.yml
sensio_framework_extra:
    router:  { annotations: true }
    request: { converters: true }
    view:    { annotations: true }
    cache:   { annotations: true }
#routing.yml
acmedemo_main:
    resource: “@AcmeDemoWebBundle/Controller”
    prefix:   /
    type: annotation
In your controller:

/**
* @Route(“/{_locale}/”, name=”localizedHomepage”)
* @Method(“POST”)
* @param $name
* @Template(“AcmeDemoWebBundle:Web:index.html.twig”)
* @Cache(expires=”+60 days”)
*/
public function localizedHomepageAction($name)
{
    return array(‘name’ => $name);
}