无法找到模板 Symfony 4
Unable to find template Symfony 4
当我从 Symfony 3.4 更新到 Symfony 4 并用浏览器显示系统时,出现以下错误。
更改 views 目录的工作量很大,我不想尽可能多地这样做。有什么好的方法吗?
错误代码
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)
{
版本
交响乐 4.0
PHP7.3
twig/twig2.14
twig/templating4.0
sensio/framework-extra-bundle5.2.4
将路径设置为 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' %}
当我从 Symfony 3.4 更新到 Symfony 4 并用浏览器显示系统时,出现以下错误。
更改 views 目录的工作量很大,我不想尽可能多地这样做。有什么好的方法吗?
错误代码
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)
{
版本
交响乐 4.0
PHP7.3
twig/twig2.14
twig/templating4.0
sensio/framework-extra-bundle5.2.4
将路径设置为 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' %}