2012-10-16 47 views
0

任何人都可以帮助我一个Symfony 2(我与它相比)。Symfony 2:PHP模板自动加载

我刚刚安装了框架,创建了我自己的包,它工作正常,直到我将模板引擎从Twig切换到PHP。

的步骤我做:

  • config.yml指定templating: { engines: ['php', 'twig'] }
  • hello.html.twig
  • 改名视图文件hello.html.php
  • 改变树枝模板代码PHP的echo

而且如果在我离开的行动里面:

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

一切OK,但是当我把它更改为:

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

的Symfony显示我的错误:找不到模板 “MyBundle:默认:index.html.twig”

+0

你清除了缓存吗? –

+0

@elnur yep,同样的错误页面 –

回答

4

我假设你使用@Template()注释?从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)
{
    // ...
}

所以,你应该添加engine="php"的注解。

+0

谢谢!这是我寻找的轴心!!))你真了不起!) –