Я хотел бы настроить Doctrine Entity Manager как публичный сервис Symfony.
Я попытался добавить следующие блоки конфигурации в services.yml (по одному):
Doctrine\ORM\EntityManagerInterface:
public: true
# [OUTPUT] Error: Cannot instantiate interface Doctrine\ORM\EntityManagerInterface
Doctrine\ORM\EntityManager:
public: true
# [OUTPUT] Invalid service "Doctrine\ORM\EntityManager": its constructor must be public.
doctrine.orm.default_entity_manager:
public: true
# [OUTPUT] The definition for "doctrine.orm.default_entity_manager" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.
Судя по выводимым сообщениям об ошибках, я подозреваю, что определения неполные, но я нигде не нашел правильного способа ручной настройки службы Doctrine Entity Manager.






Согласно комментарию Серада, мне пришлось добавить alias: 'doctrine.orm.default_entity_manager'
к моей первой попытке настройки.
Итак, правильное решение:
Doctrine\ORM\EntityManagerInterface:
public: true
alias: 'doctrine.orm.default_entity_manager'
У тебя почти получилось с первой попытки. По сути, вы хотите использовать псевдоним default_entity_manager для интерфейса. Поэтому добавьте «псевдоним: 'doctrine.orm.default_entity_manager'»