Fosuserbundle: non-existent service "templating".

Created on 21 Dec 2017  路  6Comments  路  Source: FriendsOfSymfony/FOSUserBundle


Symfony version: 4.0.2

Symfony FOSUserBundle versions: "friendsofsymfony/user-bundle": "dev-master"

friendsofsymfony/user-bundle dev-master 5d1c3ff Symfony FOSUserBundle

Description of the problem including expected versus actual behavior:

  1. Simply installing the FOSUserBundle for Symfony 4 by doing a composer require friendsofsymfony/user-bundle:dev-master
  2. Get the next exception message: The service "fos_user.mailer.default" has a dependency on a non-existent service "templating".

Problem location:

  • The problem seems to be at the line 17 at: <argument type="service" id="templating" /> in the file: /vendor/friendsofsymfony/user-bundle/Resources/config/mailer.xml
  • The service can only be one of those:

    • <argument type="service" id="templating.engine.twig" />

    • <argument type="service" id="templating.engine.php" />

    • <argument type="service" id="templating.engine.delegating" />

However, by choosing one of those services, the exception is not removed!

Thanks for your help!

Most helpful comment

I got the error away by adding the following lines to my config/packages/framework.yaml file without further changes to other files.

templating:
    engines:
        twig

I then ran my developing site, went to /register, registered a new user and activated it manually afterwards (as the email cannot be sent from my development area) without facing any issues.

All 6 comments

After some search, the next services:

  • <argument type="service" id="templating.engine.twig" />
  • <argument type="service" id="templating.engine.php" />
  • <argument type="service" id="templating.engine.delegating" />

seems to haven't a public visibility to be accessed to.

I got the error away by adding the following lines to my config/packages/framework.yaml file without further changes to other files.

templating:
    engines:
        twig

I then ran my developing site, went to /register, registered a new user and activated it manually afterwards (as the email cannot be sent from my development area) without facing any issues.

Templating service should be available in Symfony. If not, please install symfony/templating.

framework:
    templating:
        engines: ['twig', 'php']  

This is deprecated starting in Symfony 4.3:

The "framework.templating" configuration is deprecated since Symfony 4.3. Configure the "twig" section provided by the Twig Bundle instead.

As @tacman says, "framework.templating" is deprecated since Symfony 4.3.

The templating (Symfony\Bundle\FrameworkBundle\Templating\EngineInterface) is used by the class "FOS\UserBundle\Mailer\Mailer".

Until the mailer of FOSUserBundle is rewritten with the new mailer component added in Symfony 4.3, it is possible to configure FOSUserBundle to use the class "FOS\UserBundle\Mailer\TwigSwiftMailer" to work around this issue.
To do this, add the 2 lines:

聽聽聽聽 service:
聽聽聽聽聽聽聽聽 mailer: fos_user.mailer.twig_swift

at the end of the file "config/packages/fos_user.yaml"

you will be able to delete the lines:

framework:
聽聽聽聽 templating:
聽聽聽聽聽聽聽聽 engines: ['twig', 'php']

in the file "config/packages/framework.yaml"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sinner picture sinner  路  3Comments

philrennie picture philrennie  路  4Comments

mirbahar picture mirbahar  路  6Comments

DeveloperSlope3 picture DeveloperSlope3  路  5Comments

mehdimays picture mehdimays  路  6Comments