我的控制器是/src/AppBundle/Controller/TestsController.php,类是:
class TestsController extends Controller
{
/**
* @Route("/tests/index", name="testsIndex")
*/
public function indexAction(Request $request)
{
return $this->render('AppBundle::tests\index.html.twig', [
'text' => "Hello world"
]);
}
}
我的观点是/src/AppBundle/Resources/views/tests/index.html.twig并包含:
{{text}}
但是当我尝试打开http://localhost/project/web/tests/index时,错误显示:
无法找到模板“AppBundle :: tests / index.html.twig”(查看:D:\ www \ project \ app / Resources / views,D:\ www \ project \ vendor \ symfony \ symfony \ src \ Symfony \桥\嫩枝/资源/视图/表) .
我跟着这个线程,哪个错误几乎相同,但仍然找不到错误 . 这让我疯了 .
Unable to find template in Symfony 3
谢谢!
3 回答
应该工作,但尝试
AppBundle:tests:index.html.twig
.您可能还想使用大写
Tests
而不是tests
. 更常规 .Cerad的解决方案非常正确:
这应该工作 .