2016-01-15 75 views
0

我在Symfony3是新的,我用嫩枝呈现模板,一切都很好,但是当我想切换到PHP使我得到了错误:Symfony的PHP渲染

我的类:

class Testdb extends Controller 
{ 
    /** 
    * @Route("/testdb") 
    * 
    */ 
    public function testing() 
    { 
     //return $this->render('testdb.html.twig',array('result'=>$result)); 
     return $this->render('testdb.html.php',array('result'=>$result)); 
    } 

} 

我把我的testdb.html.php在app /资源/视图/ 和我编辑config.yml:

templating: 
    engines: ['twig','php'] 

的,当我浏览ttp://127.0.0.1:8000/testdb我得到The template "testdb.html.php" does not exist

+0

https://github.com/symfony/symfony/issues/15272是否为您解决它? – xabbuh

回答

2

您需要呈现模板,该模板位于您的应用程序中,或者至少指定您的模板在哪个包/应用程序中。

return $this->render(
    'AppBundle:Default:testdb.html.php', 
    array('result'=>$result) 
); 

其中AppBundle是您的应用程序的名称,而Default是您的tempalte所在的目录。