首页 > 解决方案 > symfony4 test.html.php 模板不存在

问题描述

通过编辑 config/packages/framework.yaml 启用 php 引擎后,我现在面临“模板 ::/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

标签: phpsymfony4

解决方案


我想到了。Symfony 团队还没有更新 php 模板引擎,所以它不是在templates文件夹中查找文件,而是在src/Resources/views/. 如果您要将文件放入src\Resources\views\test\test.html.php一切正常的文件中(我对其进行了测试)。


推荐阅读