class DemoController extends Controller
{
/**
* @Route("/hello/{name}", name="_demo_hello")
* @Template()
*/
public function helloAction($name)
{
return array('name' => $name);
}
// ...
}
/** * @Route("/hello/{name}", name="_demo_hello") * @Template() */
how can i move this to file routing.yml ? i would like create all routing in these file, not in action.
Take a look at this: http://symfony.com/doc/current/book/routing.html According to this documentation, your rules will look like this:
_demo_hello:
pattern: /hello/{name}
defaults:
_controller: AcmeDemoBundle:Demo:hello
However, as far as I know you can't create the @Template() behaviour in your routing file. You'll have to write the code to return a template from your controller. Like this:
public function helloAction($name)
{
return $this->render('AcmeDemoBundle:Demo:hello.html.twig', array('name' => $name));
}