Symfony 4 - no such service exists for ObjectManager after composer update
This seems to be due to the upgrade of doctrine-bundle => v2.0.0.
You have to change :
- Symfony\Bridge\Doctrine\RegistryInterface => Doctrine\Common\Persistence\ManagerRegistry
- Doctrine\Common\Persistence\ObjectManager => Doctrine\ORM\EntityManagerInterface
In your "App\Repository\AbsenceRepository" please update your constructor:
public function __construct(\Doctrine\Common\Persistence\ManagerRegistry $registry)
{
parent::__construct($registry, Address::class);
}
If not you can also come back to version 1.12.2 of doctrine-bundle
composer require doctrine/doctrine-bundle 1.12.2
Similar issue to update Symfony 4.2 to 4.4,
In practice, I search/replace in all my src/Repository/*Symfony\Bridge\Doctrine\RegistryInterface
-> Doctrine\Common\Persistence\ManagerRegistry
in USE
andRegistryInterface
-> \Doctrine\Common\Persistence\ManagerRegistry
in __construct
if you use vim (vi -p src/Repository/*.php
), here are:
:tabdo %s/Symfony\\Bridge\\Doctrine\\RegistryInterface/Doctrine\\Common\\Persistence\\ManagerRegistry/cg
:tabdo %s/RegistryInterface/\\Doctrine\\Common\\Persistence\\ManagerRegistry/cg
and my site works fine in 4.4.8
Change the Namespace of ObjectManager to Doctrine\Persistence\ObjectManager;
instead of Doctrine\Common\Persistence\ObjectManager;