Home » Php » php – There is no user provider for user "Symfony\Component\Security\Core\User\User"

php – There is no user provider for user "Symfony\Component\Security\Core\User\User"

Posted by: admin July 12, 2020 Leave a comment


After struggling all day with a simple taks for Symfony 2 with no luck, I decided to ask you guys for a solution.

Here is the problem: I would like to make a http_basic authentication using doctrine, so users would be prompted to enter username/password which are kept in a database.

So, I followed these steps:

1) Created a new entity called User with the interactive console generator.

This is how it looks like:


2) As stated in the documentation I have implemented UserInterface and added the 4 missing methods. Now the entity looks like this:


3) I have modified the security.yml as little as possible to make it work, and it looks like this:


I cleared the cache and tried to access app_dev.php/admin and of course I get the same error all day:

There is no user provider for user “Symfony\Component\Security\Core\User\User”.

500 Internal Server Error – RuntimeException

Can anyone tell me where is the problem?
I have tried this thousand different ways and weirdly it worked for a moment, but when I tried to add sha1 as encoder algorithm instead of plaintext, and cleared the cache, I came back to the same error.. since then I get nothing else but it. It is like if there is a hidden cache that is being erased whenever symfony decides 😀

I think the error might also be in the 4 methods of the entity, but I cannot fix them since there is no documentation about what should they do.

I am currently using RC4.

Thanks in advance, hope someone will help.

How to&Answers:

Had the same problem. It seems that this works. I will only use it in the development process later on i will find a solution.!

        ROLE_ADMIN:       ROLE_USER

            providers: [in_memory, user_db]
                cheese: { password: olo, roles: ROLE_ADMIN }
            entity: { class: Abc\BaseBundle\Entity\User, property: username }

        Symfony\Component\Security\Core\User\User: plaintext
        Abc\BaseBundle\Entity\User: plaintext

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

            pattern:    ^/(panel|login_check)
            anonymous: ~
                login_path:  /login
                check_path:  /login_check
                default_target_path: /panel/
                path:   /logout
                target: /


I had this problem once.

It was because I was logged with a user from the previous provider (in_memory). Had to restore the in_memory part, logout and then put the new provider.

My guess:

The info of the user was in the session and it couldn’t acces it since we took it off the security.yml


for me problem occured in dev environment. It happened because I has active session from other project.

Cleaning browser cookies helped.


You could save yourself the headache and try the friends of symfony UserBundle.

At the very least looking at that bundle will help you learn and fix your own code. It has plenty of well written code/examples.