[英]Unable to find template Symfony 4
当我从 Symfony 3.4 更新到 Symfony 4 并用浏览器显示系统时,出现以下错误。
更改视图目录需要做很多工作,我不想尽可能多地这样做。 有什么好办法吗?
错误代码
Unable to find template "AhiSpAdminBundle:Security:login.html.twig" (looked into: /home/vagrant/Symfony/src/Sp/AppBundle/Resources/views, /home/vagrant/Symfony/templates, /home/vagrant/Symfony/vendor/symfony/twig-bridge/Resources/views/Form).
代码
框架.yaml
framework:
templating:
engines: ['twig']
twig.yaml
twig:
paths: ['%kernel.project_dir%/src/App/AppBundle/Resources/views']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
安全控制器.php
/**
* @Route("/login")
* @Template("SpAppBundle:Security:login.html.twig")
*/
public function loginAction(Request $request)
{
版本
Symfony 4.0
PHP 7.3
树枝/树枝 2.14
树枝/模板 4.0
sensio/framework-extra-bundle 5.2.4
将路径设置为 twig.yaml 并进行相应的更改。
twig.yaml
twig:
paths:
'%kernel.project_dir%/src/Sp/AppBundle/Resources/views': SpApp
Controller
/**
* @Route("/login")
* @Template("@SpApp/Security/login.html.twig")
*/
public function loginAction(Request $request)
{
~.html.twig
{% extends '@SpApp/layout.html.twig' %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.