code: public function registerServices(ServicesFactory $servicesFactory, array $entityManagers)
      {
          foreach ($entityManagers as $name => $entityManager) {
              //TODO: handle isDev depending on app config
              $emConfig = Setup::createAnnotationMetadataConfiguration(
                  (array) $entityManager->getEntities(),
                  true,
                  null,
                  null,
                  true
              );
  
              $emConfig->setNamingStrategy(new UnderscoreNamingStrategy());
  
              $em = $this->createEntityManager($entityManager->toArray(), $emConfig);
  
              // register entity manager as a service
              $emServiceId = 'doctrine.em.' . Str::cast($name)->lower();
  
              $servicesFactory->registerService(['id' => $emServiceId, 'instance' => $em]);
              $servicesFactory->registerService([
                  'id' => 'db.connection.' . $name,
                  'instance' => $em->getConnection()->getWrappedConnection()
              ]);
          }
      }
docs: Register Connection and EntityManager Services
  
  @param ServicesFactory $servicesFactory
  @param EM[]            $entityManagers
  
  @throws \Doctrine\ORM\ORMException
  @throws \ObjectivePHP\ServicesFactory\Exception\ServicesFactoryException