-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli-config.php compatibility with DBAL #8327 #1070
Comments
Migration 3.x should be able to support that in a relatively easy way. Here is the place where the magic happens. It should be possible to consume the |
I am not entirely sure what you meant with the <?php
declare(strict_types=1);
use Doctrine\Migrations\DependencyFactory;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
$container = require 'config/container.php';
// For Doctrine Migration return something custom
global $argv;
if (preg_match('~doctrine-migrations~', $argv[0])) {
return $container->get(DependencyFactory::class);
}
$entityManager = $container->get(EntityManager::class);
return ConsoleRunner::createHelperSet($entityManager); It relies on Because this feel more like a workaround, than a proper official solution, I keep the issue open, even though I probably won't investigate any further myself. |
HI @PowerKiKi @goetas <?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Helper\QuestionHelper;
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\OutputWriter;
use Doctrine\Migrations\Tools\Console\Helper\ConfigurationHelper;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\EntityManager;
$em = $container->get('doctrine.entity_manager.orm_default');
$connection = $em->getConnection();
$appConfig = $container->get('config');
$migrationsConfig = $appConfig['doctrine']['migrations_configuration'];
$output = new ConsoleOutput();
$writer = new OutputWriter(function ($message) use ($output) {
$output->writeln($message);
});
$configuration = new Configuration($connection, $writer);
$configuration->setMigrationsDirectory($migrationsConfig['directory']);
$configuration->setMigrationsNamespace($migrationsConfig['namespace']);
$configuration->setMigrationsTableName($migrationsConfig['table']);
$helperSet = ConsoleRunner::createHelperSet($em);
$helperSet->set(new ConfigurationHelper($connection, $configuration)); <<<<< this one
$helperSet->set(new QuestionHelper(), 'dialog');
$application = ConsoleRunner::createApplication($helperSet);
Doctrine\Migrations\Tools\Console\ConsoleRunner::addCommands($application);
$application->addCommands(getCustomCommands($appConfig, $container));
$application->run(); |
Or is this a proper way to do it on v3.3.2? $configuration = new Configuration();
$configuration->addMigrationsDirectory($migrationsConfig['namespace'], $migrationsConfig['directory']);
$tableMetadataStorageConfiguration = new TableMetadataStorageConfiguration();
$tableMetadataStorageConfiguration->setTableName($migrationsConfig['table']);
$configuration->setMetadataStorageConfiguration($tableMetadataStorageConfiguration);
$dependencyFactory =
DependencyFactory::fromConnection(new ExistingConfiguration($configuration), new ExistingConnection($connection));
$helperSet = ConsoleRunner::createHelperSet($em);
$helperSet->set(new QuestionHelper(), 'dialog');
$application = ConsoleRunner::createApplication($helperSet);
Doctrine\Migrations\Tools\Console\ConsoleRunner::addCommands($application);
$application->addCommands(getCustomCommands($appConfig, $container));
$application->addCommands(new \Doctrine\Migrations\Tools\Console\Command\MigrateCommand($dependencyFactory));
$application->addCommands(new \Doctrine\Migrations\Tools\Console\Command\DiffCommand($dependencyFactory));
$application->run(); |
Feature Request
Summary
Since DBAL 2.11.0 and doctrine/dbal#3956, it is now deprecated to use HelperSet in
cli-config.php
. This will become impossible in DBAL 3, following doctrine/dbal#4059.This means that, in order to keep sharing a single config file for both packages, this package should also accept the new
\Doctrine\DBAL\Tools\Console\ConnectionProvider
. It could actually be a new interface along the lines of:I suppose the support of HelperSet could be drop entirely in the next major version too.
See related doctrine/orm#8327
The text was updated successfully, but these errors were encountered: