Search code examples
symfonytwigsymfony-2.7symfony-3.1symfony-3.2

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


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


Solution

  • 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.