Answer the question
In order to leave comments, you need to log in
Multiple interface implementations, how to determine which DInject implementation?
There is a UserRepo interface and there are 2 implementations, DoctrineUserRepo and InMemoryUserRepo for mocks. Symphony service container is throwing an error now
Cannot autowire service...: argument "$userRepository" of method "__construct()" references interface "UserReposito
ry" but no such service exists. You should maybe alias this interface to one of these existing services: "...DoctrineUserRepository", "....InMemoryUserRepository".
Answer the question
In order to leave comments, you need to log in
The documentation mentions this: https://symfony.com/doc/current/service_container/...
# services.yml
services:
App\Repository\UserRepoInterface: '@App\Repository\DoctrineUserRepo'
# services_test.yml
services:
App\Repository\UserRepoInterface: '@App\Repository\InMemoryUserRepo'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question