当我从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
wig/templating 4.0
sensio/framework-extra-bundle 5.2.4
1条答案
按热度按时间pnwntuvh1#
将路径设置为twig.yaml并进行相应的更改就可以了。
twig.yaml
控制器
~.html. wig