roadrunner-bundle icon indicating copy to clipboard operation
roadrunner-bundle copied to clipboard

DoctrineBundle doesn't infer use of ORM

Open brzuchal opened this issue 2 years ago • 5 comments

Use of DoctrineBundle doesn't mean an ORM and any ManagerRegistry is available and yet you assume it is here https://github.com/Baldinof/roadrunner-bundle/blob/2.x/src/DependencyInjection/BaldinofRoadRunnerExtension.php#L131-L142

At a container compile time an error like this is thrown:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
                                                                                                                                                                         
  The service "Baldinof\RoadRunnerBundle\Integration\Doctrine\DoctrineORMMiddleware" has a dependency on a non-existent service "Doctrine\Persistence\ManagerRegistry".  
 

brzuchal avatar Mar 23 '22 17:03 brzuchal

Hi!

You are right, sorry I don't use doctrine (orm or dbal) myself. I guess we could remove the middleware if no manager service exists in a compiler pass.

Do you see other thing that should be handled by the middleware if only dbal is used?

Baldinof avatar Mar 27 '22 21:03 Baldinof

I tried to play a little with doctrine bundle, if I use doctrine.orm: {}, I still get a valid ManagerRegistry and the middlware is working.

What version of Doctrine Bundle are you using?

Baldinof avatar Mar 28 '22 21:03 Baldinof

@Baldinof remove doctrine.orm from the config this is the thing, it is allowed to use only doctrine.dbal which don't register any ManagerRegistry

brzuchal avatar Apr 08 '22 16:04 brzuchal

I cannot reproduce your issue with the last version of doctrine bundle. There is still a registry injected, it simply does not have any entity managers, and simply provides dbal connections (which get closed / pinged if needed).

Can you try to replace this line by

                ->addArgument(new Reference('doctrine'))

Also, what version of doctrine bundle / symfony / roadrunner-bundle are you using?

Baldinof avatar Apr 18 '22 10:04 Baldinof

Any news @brzuchal ?

Baldinof avatar Apr 29 '22 21:04 Baldinof