While I was playing with GraphQL in Symfony I wanted to use a pre-symfony 4 bundle to provide a GraphQL server. When I wanted to go to a page that used a twig template I got the following error:
Unable to find template "GraphQLBundle:Feature:explorer.html.twig" (looked into: /var/www/templates, /var/www/templates, /var/www/vendor/symfony/twig-bridge/Resources/views/Form).
Since I haven’t been working with Symfony 4 that long I was surprised that this didn’t work. In Symfony 3.x this didn’t give any issues.
After some searching, I found this issue where they explain that the “x:x:x.html.twig” notation is no longer supported by default in Symfony 4. In order to enable support for this you need to do two things:
- Install the templating component using the following command
$ composer require templating
- Add the following lines to config/packages/framework.yml
templating: engines: ['twig']
As soon as you have performed these steps, Symfony 4 will now understand how to find templates with colons in them!
Update: Christophe Coevoet mentioned on Twitter that this notation will become deprecated in a future 4.x.x release; so this trick will only have a limited lifetime.