2014-09-01 71 views
0

它将.twig的改变值改变为.php?Symfony2从.twig到.php的意见

现在试图生成CRUD(与作曲家),并得到.twig的意见,但我需要得到它在PHP中。

+0

为什么由你想使用的PHP,而不是树枝的方式吗? Twig实际上比用于模板的php功能更强大,特别适用于CRUD设计:)你应该发布你的需求,以便我们能够用树枝来帮助你:) – 2014-09-01 13:11:05

+0

在项目中使用.php,所以我需要使用php。它不是新的项目。 :)所以我试图找到方法来从作曲家建立PHP视图。 – Dzi 2014-09-01 13:22:58

回答

2

这里是如何实现的官方文档此

# app/config/config.yml 
framework: 
    # ... 
    templating: 
     engines: ['twig', 'php'] 

// src/Acme/HelloBundle/Controller/HelloController.php 

// ... 
public function indexAction($name) 
{ 
    return $this->render(
     'AcmeHelloBundle:Hello:index.html.php', 
     array('name' => $name) 
    ); 
} 

http://symfony.com/doc/current/cookbook/templating/PHP.html

+0

我试图从作曲家那里得到“index.html.php”。 – Dzi 2014-09-01 13:22:00

+0

从作曲家?你能写一些代码,或者提供更多细节吗? – 2014-09-01 13:26:35

+0

然后我们使用这个:http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_doctrine_crud.html它将在bundle中创建控制器和视图。但是,视图以my_views.twig格式显示,但我需要获取my_views.php :) – Dzi 2014-09-01 13:29:15