我正在尝试使用php显示一个symfony模板.但是,symfony将我的php标签视为"评论"
我的控制器
namespace Acme\testBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class testController extends Controller
{
public function helloAction()
{
//return new Response('Created product id ');
return $this->render('AcmetestBundle:test:test.html.php');
}
}
Run Code Online (Sandbox Code Playgroud)
我的模板:test.html.php
<?php var_dump("Hello world");?>
Run Code Online (Sandbox Code Playgroud)
我的输出:
<!--?php var_dump("Hello world");?-->
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
可能只需要将php作为模板引擎添加到您的配置文件中.
templating: { engines: ['twig','php'] }
Run Code Online (Sandbox Code Playgroud)