SYMFONY3 in prod look for TWIG template in wrong folder instead of custom bundle indicated in routing.yml and AppKernel.php

故事扮演 提交于 2019-12-12 06:05:22

问题


I am implementing a SYMFONY 3 project in production mode for the first time.

I follow 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/?


回答1:


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.



来源:https://stackoverflow.com/questions/43136638/symfony3-in-prod-look-for-twig-template-in-wrong-folder-instead-of-custom-bundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!