[英]Unable to find template Symfony 4
When I updated from Symfony 3.4 to Symfony 4 and displayed the system with a browser, the following error appeared.当我从 Symfony 3.4 更新到 Symfony 4 并用浏览器显示系统时,出现以下错误。
Changing the views directory is a lot of work and I don't want to do it as much as possible.更改视图目录需要做很多工作,我不想尽可能多地这样做。 Is there any good way?有什么好办法吗?
Error Code错误代码
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).
Code代码
framework.yaml框架.yaml
framework:
templating:
engines: ['twig']
twig.yaml twig.yaml
twig:
paths: ['%kernel.project_dir%/src/App/AppBundle/Resources/views']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
SecurityController.php安全控制器.php
/**
* @Route("/login")
* @Template("SpAppBundle:Security:login.html.twig")
*/
public function loginAction(Request $request)
{
Version版本
Symfony 4.0 Symfony 4.0
PHP 7.3 PHP 7.3
twig/twig 2.14树枝/树枝 2.14
twig/templating 4.0树枝/模板 4.0
sensio/framework-extra-bundle 5.2.4 sensio/framework-extra-bundle 5.2.4
Setting the path to twig.yaml and the accompanying changes worked.将路径设置为 twig.yaml 并进行相应的更改。
twig.yaml twig.yaml
twig:
paths:
'%kernel.project_dir%/src/Sp/AppBundle/Resources/views': SpApp
Controller Controller
/**
* @Route("/login")
* @Template("@SpApp/Security/login.html.twig")
*/
public function loginAction(Request $request)
{
~.html.twig ~.html.twig
{% extends '@SpApp/layout.html.twig' %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.