[英]symfony4 test.html.php template does not exist
After enabling the php engine by editing the config/packages/framework.yaml, I am now facing the "The template ::/test/test.html.php" does not exit" error !! 通过编辑config / packages / framework.yaml启用php引擎后,我现在面临“模板:: / test / test.html.php不会退出”错误!
Controller : 控制器:
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class TestController extends Controller
{
/**
* @Route("/test.html.php", name="testphp")
*/
public function testphp(){
return $this->render('test/test.html.php');
}
}
Path: Templates/test/test.html.php 路径: Templates / test / test.html.php
I figured it out. 我想到了。 The Symfony team has not yet updated the php templating engine, so it looks for files not in the
templates
folder, but in src/Resources/views/
. Symfony团队尚未更新php模板引擎,因此它不在
src/Resources/views/
目录中查找文件而不位于templates
文件夹中。 If you were to put your file in src\\Resources\\views\\test\\test.html.php
everything works (I tested it). 如果将文件放在
src\\Resources\\views\\test\\test.html.php
一切正常(我已经对其进行了测试)。
运行composer require symfony / twig-bundle,您将获得带有base.html.twig文件的模板文件夹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.