symfonydoctrine-ormrepository

The class 'App\Repository\Users\UserRepository' was not found in the chain configured namespaces App\Entity\Users


I've seen a few questions about this error message but the answers weren't helpful to me so here we go again:

I have 2 configured entity managers and when I call

$repository = $this->getManager('db_users')->getRepository(UserRepository::class));

it throws the error

The class 'App\Repository\Users\UserRepository' was not found in the chain configured namespaces App\Entity\Users.

So it's the repository problem (or isn't it? Symfony likes to throw errors absolutely not related to the real problem).

Could anyone tell me what I did incorrect? Thanks for any help.


Solution

  • You need to pass the entity class name, instead of the repository class name, like this:

    ->getRepository(User::class)