andreaem
andreaem

Reputation: 1655

Symfony 3.4 - non existent service when installing FOSUserBundle

I've just started a new blank project using Symfony 3.4 and first of all configured FOSUserBundle following this Documentation page.

I've tried two times deleting all and start from scratch again but I got this error during clearing cache:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:

  The service "security.authentication.provider.dao.main" has a dependency on a non-existent service "fos_user.user_checker". 

config.yml

[...]
fos_user:
    db_driver: orm # other valid values are 'mongodb' and 'couchdb'
    firewall_name: main
    user_class: AppBundle\Entity\User
    from_email:
        address: "%mailer_user%"
        sender_name: "%mailer_user%"

parameters.yml

parameters:
    database_path: '%kernel.project_dir%/var/data/data.sqlite'
    mailer_transport: smtp
    mailer_host: smtp.mailtrap.io
    mailer_user: ***
    mailer_password: ***
    secret: ***

routing.yml

app:
    resource: '@AppBundle/Controller/'
    type: annotation
fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

security.yml

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        main:
            pattern: ^/
            user_checker: fos_user.user_checker
            form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager

            logout:       true
            anonymous:    true

    access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }

Obviously I've add new FOS\UserBundle\FOSUserBundle(), in AppKernel.php

$bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new AppBundle\AppBundle(),
        ];

I'm using version 2.0 of FOSUserBundle and Symfony 3.4.

Upvotes: 1

Views: 2519

Answers (1)

FoFoCuddlyPoops
FoFoCuddlyPoops

Reputation: 147

For Symfony 3.4 and FOSUserBundle 2.1 this issue appears to continue to exist.

Fix: Change the following in security.yml

security:
    firewalls:
        main:
            user_checker: fos_user.user_checker

to

security:
    firewalls:
        main:
            user_checker: security.user_checker

Upvotes: 3

Related Questions