我一直在尝试将我自己的Doctrine\Dbal\Connection对象与 Doctrine Migrations 一起使用,这是我目前得到的,但它一直告诉我提供一个--db-configuration文件,这不是我想要的。
// CLI script for Doctrine Migrations
$app = require 'bootstrap.php';
$cli = new Symfony\Component\Console\Application('Doctrine CLI');
$cli->addCommands([
new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand()
]);
$helperSet = new Symfony\Component\Console\Helper\HelperSet([
// Doctrine\DBAL\Connection $app->getContainer()->db
'connection' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($app->getContainer()->db),
'dialog' => new \Symfony\Component\Console\Helper\QuestionHelper(),
]);
$cli->setHelperSet($helperSet);
$cli->run();
例外:
[InvalidArgumentException]
You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrat
ions.