symfony4 test.html.php模板不存在



通过编辑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文件的模板文件夹

最新更新