[PR #11476] Added a new manager to manage multiple entity manager instances #13052

Open
opened 2026-01-22 16:16:01 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/11476

State: closed
Merged: No


Hi,

I encountered a problem with the console, I would have liked to be able to pass several instances of the entity manager.
Currently, only one instance can be passed using SingleManagerProvider class.

Here is a new implementation of the MultipleManagerProvider class.
It allows you to obtain several instances of the Entity manager within a console application.

Here is how it could be instantiated:

#!/usr/bin/env php
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\MultipleManagerProvider;

$em1 = GetEntityManager();
$em2 = GetEntityManager();

$commands = [
    // If you want to add your own custom console commands,
    // you can do so here.
];

$multipleManagerProvider = new MultipleManagerProvider(['em1' => $em1, 'em2' => $em2]);
ConsoleRunner::run($multipleManagerProvider, $commands);

It's now possible to execute the binary with the argument --em=em1 or --em=em2

**Original Pull Request:** https://github.com/doctrine/orm/pull/11476 **State:** closed **Merged:** No --- Hi, I encountered a problem with the console, I would have liked to be able to pass several instances of the entity manager. Currently, only one instance can be passed using `SingleManagerProvider` class. Here is a new implementation of the `MultipleManagerProvider` class. It allows you to obtain several instances of the `Entity manager` within a console application. Here is how it could be instantiated: ```php #!/usr/bin/env php <?php use Doctrine\ORM\Tools\Console\ConsoleRunner; use Doctrine\ORM\Tools\Console\EntityManagerProvider\MultipleManagerProvider; $em1 = GetEntityManager(); $em2 = GetEntityManager(); $commands = [ // If you want to add your own custom console commands, // you can do so here. ]; $multipleManagerProvider = new MultipleManagerProvider(['em1' => $em1, 'em2' => $em2]); ConsoleRunner::run($multipleManagerProvider, $commands); ``` It's now possible to execute the binary with the argument `--em=em1 `or `--em=em2`
admin added the pull-request label 2026-01-22 16:16:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13052