Q:

Non-existent service "fos_user.user_provider.username_email"

I am following the guide to install FOSUserBundle located at https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md 
My security file:
security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            logout:       true
            anonymous:    true

    access_control:
        - { path: ^/admin/, role: ROLE_ADMIN }

however after doing all steps, I am getting one error:
ServiceNotFoundException: The service "security.authentication.manager" has a dependency on a non-existent service "fos_user.user_provider.username_email". 

What could be causing it? 

A:

You are using FOSUserBundle 1.0 which does not have the username_email provider.   Upgrade to FOSUserBundle 2.0 by changing composer.json to: "friendsofsymfony/user-bundle": "dev-master",
The 2.0 version has plenty of good stuff in it including a bunch of useful events.   Unfortunately, it has never been officially released as a stable version.   Hence the dev-master version.