通过编辑config/packages/framework.yaml启用php引擎后,我现在面临"模板::/test/test.html.php"不退出"错误!!
控制器:
namespace AppController;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyBundleFrameworkBundleControllerController;
class TestController extends Controller
{
/**
* @Route("/test.html.php", name="testphp")
*/
public function testphp(){
return $this->render('test/test.html.php');
}
}
路径:模板/test/test.html.php
我想明白了。Symfony团队尚未更新php模板引擎,因此它不在templates
文件夹中查找文件,而是在src/Resources/views/
中查找文件。如果你把你的文件放在srcResourcesviewstesttest.html.php
中,一切都可以(我测试了它(。
运行composer require symfony/tritch bundle,您将获得一个带有base.html.twig文件的模板文件夹