container->get(EntityManagerInterface::class); } catch (Throwable) { $em = null; } if ($em) { $commands = require $this->rootDir . '/config/commands.php'; $emp = new SingleManagerProvider($em); $cp = new ConnectionFromManagerProvider($emp); $config = new PhpFile($this->rootDir . '/config/migrations.php'); $df = DependencyFactory::fromEntityManager( $config, new ExistingEntityManager($em) ); $this->app ->set(EntityManagerProvider::class, $emp) ->set(ConnectionProvider::class, $cp) ->set(DependencyFactory::class, $df); } else { $commands = []; } $commandLoader = new ContainerCommandLoader( $this->container, $commands ); $app = new ConsoleApplication('Console'); $app->setCommandLoader($commandLoader); $this->app->set(ConsoleApplication::class, $app); } }