symfony4 test.html.php 模板不存在

symfony4 test.html.php template does not exist

通过编辑 config/packages/framework.yaml 启用 php 引擎后,我现在面临 "The template ::/test/test.html.php" 不退出”错误!!

控制器:

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');
    }
}

路径:Templates/test/test.html.php

我明白了。 Symfony 团队尚未更新 php 模板引擎,因此它查找的文件不在 templates 文件夹中,而是在 src/Resources/views/ 中。如果您将文件放在 src\Resources\views\test\test.html.php 中,一切正常(我测试过)。

运行 composer require symfony/twig-bundle 你会得到一个包含 base.html.twig 文件的模板文件夹