0

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

nyluje
  • 3,573
  • 7
  • 37
  • 67
  • You have to configure or add the folder to `Twig`,`$loader = new Twig_Loader_Filesystem(array($templateDir1, $templateDir2));` or `$loader->addPath([my symf project]\src\MyBundle\Ressources\views);` – DarkBee Mar 31 '17 at 09:07
  • Change "MyBundle:std_page:home.html.twig" to "@MyBundle/std_page/home.html.twig" in your controller. – Andrzej Piszczek Mar 31 '17 at 09:30
  • @DarkBee in which file (and folder) of the symfony project this line is supposed to be? – nyluje Mar 31 '17 at 09:57
  • @AndrzejPiszczek thanks for your input but your solution leads to change everything with no guarantee it will work at the end (I mean by that I get different error messages). Moreover SYMFONY best practices states that the TWIG template name pattern in a bundle should use colon (cf: http://symfony.com/doc/current/templating.html#referencing-templates-in-a-bundle). I prefer to not drift away from those recommendations. – nyluje Mar 31 '17 at 10:27
  • Looks like you do it like [this](http://stackoverflow.com/questions/20050384/define-custom-filesystem-path-for-twig-templates) – DarkBee Mar 31 '17 at 11:17

1 Answers1

2

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.

Community
  • 1
  • 1
nyluje
  • 3,573
  • 7
  • 37
  • 67