Baldinof / roadrunner-bundle

A RoadRunner worker integrated in your Symfony app
MIT License
270 stars 48 forks source link

DoctrineBundle doesn't infer use of ORM #79

Open brzuchal opened 2 years ago

brzuchal commented 2 years ago

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".  
Baldinof commented 2 years ago

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 commented 2 years ago

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?

brzuchal commented 2 years ago

@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

Baldinof commented 2 years ago

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 commented 2 years ago

Any news @brzuchal ?