【发布时间】:2018-02-06 06:51:38
【问题描述】:
请帮忙,symfony 4 找不到 php 模板。
错误是模板“::test/index.html.php”不存在。
控制器:
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class TestController extends Controller
{
public function number()
{
$number = mt_rand(0, 100);
// return new Response(
// '<html><body>Lucky number: '.$number.'</body></html>'
// );
return $this->render("test/number.html.php",
array('number' => $number));
}
function index() {
return $this->render("test/index.html.php");
}
}
目录:
- 模板/
- 测试/
- index.html.php
- number.html.php
- 测试/
谢谢
【问题讨论】:
-
你是否使用
twig作为模板引擎? -
不,我正在使用 PHP 模板,已在配置中启用它
-
可能重复,看这个帖子:link
-
symfony 4 中没有
app/文件夹,模板有templates/文件夹 -
也不行,试了链接改了:
return $this->render("App:Test:index.html.php");
标签: php symfony templates symfony4