How to solve Symfony 4 Error: During class fetch: Uncaught ReflectionException: Class Symfony\Component\Templating\Helper\Helper not found in vendor/symfony/security-bundle/Templating/Helper/LogoutUrlHelper.php

How to solve Symfony 4 Error: During class fetch: Uncaught ReflectionException: Class Symfony\Component\Templating\Helper\Helper not found in vendor/symfony/security-bundle/Templating/Helper/LogoutUrlHelper.php

In some versions of Symfony 4, specifically in the development environment, the following exception will appear when trying to access any route of your app:

FatalErrorException
Error: During class fetch: Uncaught ReflectionException: Class Symfony\Component\Templating\Helper\Helper not found in /vendor/symfony/security-bundle/Templating/Helper/LogoutUrlHelper.php:23
Stack trace:
#0 /vendor/symfony/debug/DebugClassLoader.php(143): require('/var/www/vhosts...')
#1 [internal function]: Symfony\Component\Debug\DebugClassLoader->loadClass('Symfony\\Bundle\\...')
#2 [internal function]: spl_autoload_call('Symfony\\Bundle\\...')
#3 /vendor/symfony/config/Resource/ClassExistenceResource.php(76): class_exists('Symfony\\Bundle\\...')
#4 /vendor/symfony/dependency-injection/ContainerBuilder.php(349): Symfony\Component\Config\Resource\ClassExistenceResource->isFresh(0)
#5 /vendor/sy

The error is triggered basically by the missing Templating classes of the Symfony Templating package. The Templating component provides all the tools needed to build any kind of template system. It provides an infrastructure to load template files and optionally monitor them for changes. It also provides a concrete template engine implementation using PHP with additional tools for escaping and separating templates into blocks and layouts.

You can easily fix this issue by installing the component with composer:

composer require symfony/templating

And that's it, you will be able to clear the cache of the application as well and access any route.

Happy coding !

This could interest you

Become a more social person