ok this might be a very strange thing. it's not the first time I work a symfony project but:
I used the symfony generate:bundle command and after that I created a bundle. Lets call it "CrimeBundle".
I saw it made a folder inside the src/
It also made automatically a DefaultController and an index.html.twig file.
Now whenever I use:
return $this->render('CrimeBundle:Default:index.html.twig');
it doesn't work: I get the error:
Unable to find template "CrimeBundle:Default:index.html.twig" (looked into: /Users/admin/sites/solve/app/Resources/views, /Users/admin/sites/solve/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).
however it works whenever I use the namespaced twig path like:
return $this->render('@Crime/Default/index.html.twig');
I like the first option, because on my other projects I use it too. None of them are the same version, currently I use: 3.4.1 Again the file is there, because it works with namespaced twig paths.
I can't understand why return $this->render('CrimeBundle:Default:index.html.twig');
wouldn't work as symfony generated this code.
According to this - https://symfony.com/doc/3.4/templating.html#referencing-templates-in-a-bundle That's the only reference type the support for bundle templates
@BundleName/directory/filename.html.twig
If you go to docs for symfony 3.1 you'll see that was the last version that supported old reference
AcmeBlogBundle:Blog:index.html.twig
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With