Symfony 4 FOSUserBundle: The service “fos_user.resetting.controller” has a dependency on a non-existent service “templating”

This post shares you how to solve this error when integrating FOSUserBundle into Symfony 4.

Specifically when I run the following command to update my database schema:

php bin/console doctrine:schema:update --force

this error is thrown:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:

  The service "fos_user.resetting.controller" has a dependency on a non-existent service "templating".

 
To solve this error, you can follow one of two ways:

  • Way 1: set the below config in config/packages/framework.yaml
framework.yaml
framework:
    templating:
        engines: ['twig']

 

  • Way 2: set the below config in config/packages/fos_user.yaml
service:
    mailer: fos_user.mailer.twig_swift

The complete fos_user.yaml looks like:

fos_user.yaml
fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: App\Entity\User
    registration:
        form:
            type: App\Form\Type\RegistrationFormType
    from_email:
        address: "yourapp@yourapp.com"
        sender_name: "Demo String"
    service:
        mailer: fos_user.mailer.twig_swift

Leave a Reply

avatar