当我从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).码
framework.yaml
framework:
templating:
engines: ['twig']twig.yaml
twig:
paths: ['%kernel.project_dir%/src/App/AppBundle/Resources/views']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'SecurityController.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-额外- 5.2.4包
发布于 2021-01-19 05:29:17
设置到twig.yaml的路径和相应的更改是有效的。
twig.yaml
twig:
paths:
'%kernel.project_dir%/src/Sp/AppBundle/Resources/views': SpApp控制器
/**
* @Route("/login")
* @Template("@SpApp/Security/login.html.twig")
*/
public function loginAction(Request $request)
{~.html.twig
{% extends '@SpApp/layout.html.twig' %}https://stackoverflow.com/questions/65771718
复制相似问题