0

Can anyone help me with a Symfony 2 (I'm newby with it).

I just installed framework, created my own bundle and it worked fine till I switched template engine from Twig to PHP.

The steps I did:

  • specified templating: { engines: ['php', 'twig'] } in config.yml
  • renamed view file from hello.html.twig to hello.html.php
  • changed twig template code to php's echo

Also if inside the action I leave:

return $this->render('MyBundle:Default:index.html.php', array('name' => $name));

all OK, but when I changes it to:

return array('name' => $name);

Symfony shows me an error: Unable to find template "MyBundle:Default:index.html.twig"

1
  • @elnur yep, the same error page Commented Oct 16, 2012 at 20:31

1 Answer 1

4

I assume you use the @Template() annotation? From the official documentation:

If you are using PHP as a templating system, you need to make it explicit::

/**
  * @Template(engine="php")
  */
public function showAction($id)
{
    // ...
}

So you should add engine="php" to the annotation.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks!! This is axactly what i have looked for!!)) you're amazing ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.