Learn why this exception occurs while implementing FOSUserBundle in Symfony 3.4.

In the latest release of Symfony 3 namely the 3.4 version, the default structure and dependencies of an empty project changed. One of the changes that affects developers that want to install FOSUserBundle, is the inexistence of the Twig templating service that FOSUserBundle requires.

Solution

If you really want to implement the FOSUserBundle in your project, you will need to satisfy the necessary dependencies. In this case, you will need to install the templating component of Symfony with composer using the following command:

Note

Is very important that if you are using Symfony 3.4, to install as well the latest 3.4.x version of the templating component as upcoming version are compatible only with Symfony 4.x. If you install the component using only composer require symfony/templating.

composer require symfony/templating v3.4.2

After installing this component, enable the twig template engine in your config.yml file under the framework key:

# app/config/config.yml
framework:
    templating:
        engines: ['twig']

Finally clear cache if necessary and the problem shouldn't appear anymore.

Happy coding !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors