产品中的SYMFONY3在错误的文件夹中查找TWIG模板,而不是routing.yml和AppKernel.php中指示的自定义包 [英] SYMFONY3 in prod look for TWIG template in wrong folder instead of custom bundle indicated in routing.yml and AppKernel.php

查看:94
本文介绍了产品中的SYMFONY3在错误的文件夹中查找TWIG模板,而不是routing.yml和AppKernel.php中指示的自定义包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次以生产模式实施SYMFONY 3项目.

我遵循标准文档.

我解决了与用户写权有关的一堆问题,现在我得到了一个SYMFONY ERROR页面(距胜利一步一步),并显示以下消息:

无法找到模板"MyBundle:std_page:home.html.twig"(已查找 进入:/[symf项目文件夹]/app/Resources/views, /[symf专案资料夹]/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form, /[symf专案资料夹]/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views).

如果我查看我的[symf项目] \ app \ config \ routing.yml,就会发现:

my_bundle:
  resource: "@MyBundle/Resources/config/routing.yml"
  options:
      expose: true

在[我的symf项目] \ app \ AppKernel.php中,在registerBundles()函数中,我具有:

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ....
             new MyBundle\MyBundle(),
           .....
         ]
    }
}

并且存在有关应提取[my symf project]\src\MyBundle\Ressources\views/std_page/home.html.twig的模板的文件.

在生产模式下,我没有正确设置什么以使其在文件夹[my symf project]\src\MyBundle\Ressources\views/中寻找TWIG模板吗?

解决方案

经过一番搜索,它碰巧是一个与OceanDigital tutorial and the standard doc.

I went thru a bunch of issues linked to user writing rights that I've solved, and I do get now a SYMFONY ERROR page (one step closer to victory) with this message:

Unable to find template "MyBundle:std_page:home.html.twig" (looked into: /[folder to symf project]/app/Resources/views, /[folder to symf project]/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form, /[folder to symf project]/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views).

If I look in my [my symf project]\app\config\routing.yml, I have:

my_bundle:
  resource: "@MyBundle/Resources/config/routing.yml"
  options:
      expose: true

In [my symf project]\app\AppKernel.php, in the registerBundles() function, I have:

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ....
             new MyBundle\MyBundle(),
           .....
         ]
    }
}

And the file regarding the template that should be fetched [my symf project]\src\MyBundle\Ressources\views/std_page/home.html.twig exists.

What did I not set up right, in production mode, to have it looking for the TWIG template in the folder [my symf project]\src\MyBundle\Ressources\views/?

解决方案

After some search it happens to be a mistake similar to the one described in that SO thread.

In my controller I had:

return $this->render('MyBundle:Std_page:home.html.twig',$parameters);

Instead of:

return $this->render('MyBundle:std_page:home.html.twig',$parameters);

The development was made on a WINDOWS 10 OS, and it is set up in production on a UBUNTU 16.04. It seems that UBUNTU is stricter than WINDOWS regarding the letter case.

这篇关于产品中的SYMFONY3在错误的文件夹中查找TWIG模板,而不是routing.yml和AppKernel.php中指示的自定义包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆