Symfony2 routing with annotations Symfony2 routing with annotations symfony symfony

Symfony2 routing with annotations


# app/config/routing.ymlMunichInnovationGroupPatentBundle:    resource: "@MunichInnovationGroupPatentBundle/Controller/DefaultController.php"    type:     annotation    prefix:   /

The controller should have:

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;


If you are in the developement environment check you import the routing.yml in routing_dev.yml:

# app/config/routing_dev.yml_main:    resource: routing.yml


Add following code in your bundle MunichInnovationGroup/PatentBundle/Resources/config/routing.yml

_admin_emailTemplate:    pattern: admin/emailTemplate    defaults: {_controller: DashboardEmailTemplateBundle:Default:index }requirements: { _method: GET | POST }

Above is just an example of bundle. You only have to post bold text "requirements".