admin管理员组文章数量:1181449
I come here after a long day of debugging.
I get the following error on my Symfony 7 project:
Cannot autowire service "App\Infrastructure\Persistence\DoctrineConcreteRepository": argument "$entityManager" of method "__construct()" references interface
"Doctrine\ORM\EntityManagerInterface" but no such service exists. Did you create a class that implements this interface?
I already installed doctrine/orm.
I configured the services.yaml:
Doctrine\ORM\EntityManagerInterface: '@doctrine.orm.default_entity_manager'
and doctrine.yaml:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_sqlite'
charset: utf8mb4
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
Then:
public function __construct(private Connection $connection, private EntityManagerInterface $entityManager)
And the services.yaml is quite simple:
services:
_defaults:
autowire: true
autoconfigure: true
App\Application\Repository\MyRepositoryInterface: '@App\Infrastructure\Persistence\MyDoctrineRepository'
App\Infrastructure\Persistence\MyDoctrineRepository:
arguments:
$entityManager: '@doctrine.orm.default_entity_manager'
Doctrine\ORM\EntityManagerInterface: '@doctrine.orm.default_entity_manager'
but when I clear the cache, or run the program, I get the error.
Any help?
本文标签:
版权声明:本文标题:symfony - argument "$entityManager" of method "__construct()" references interface " 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738238763a2070817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论