The service “fos_user.mailer” has a dependency on a non-existent service “templating”

前端 未结 3 1822
逝去的感伤
逝去的感伤 2020-12-28 12:53

So, the above error has suddenly started happening, after I\'ve been using FOSUserBundle for several Symfony projects.

I\'ve tried including the templating service (

相关标签:
3条回答
  • 2020-12-28 13:22

    In Symfony 3.4 and FosUserBundle 2.0, add a service mailer into the fos_user config:

    fos_user:
        db_driver: orm # other valid values are 'mongodb' and 'couchdb'
        firewall_name: main
        user_class: AppBundle\Entity\User
        service:                               # this lines
            mailer: fos_user.mailer.twig_swift # this lines
        from_email:
            address: "%mailer_user%"
            sender_name: "%mailer_user%
    
    0 讨论(0)
  • 2020-12-28 13:31

    I just experienced the exact same problem. The funny thing is that I created a Symfony 3.3 project just before creating a Symfony 3.4 project and the Symfony 3.3 project didn't have this problem. So they must have removed the templating component for the 3.4 release.

    To solve your problem, you will have to install the templating component using composer:

    composer require symfony/templating
    

    Then, add the following configuration under the framework key in your config.yml:

    templating:
        engines: ['twig']
    

    Update: I recently had to start a new Symfony 3.4 project with FOSUserBundle and discovered that I only had to add the above configuration to my config.yml file (as was mentioned in a comment below).

    0 讨论(0)
  • 2020-12-28 13:31

    For my case, it's work after changing in the config.yml like below:

    # FOSUser Configuration
    fos_user:
        db_driver: orm # other valid values are 'mongodb' and 'couchdb'
        firewall_name: main
        user_class: AppBundle\Entity\User
        service:                               # this line
            mailer: fos_user.mailer.twig_swift # this line (from the comment above)
        from_email:
            address: "test@test.com" # change this 
            sender_name: "Test App"  # and this
    
    0 讨论(0)
提交回复
热议问题