8

我正在尝试在 silex 框架之上设置学说迁移。我通过作曲家安装了它。

"doctrine/dbal": "2.3.*",
"doctrine/migrations": "dev-master",

我的控制台文件:

...
$app['composer_loader']->add('Doctrine\DBAL\Migrations', __DIR__.'/../vendor/doctrine/migrations/lib/');

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
    "db" => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($app['db']),
    "dialog" => new \Symfony\Component\Console\Helper\DialogHelper(),
));
$console->setHelperSet($helperSet);

$console->addCommands(array(
    // Migrations Commands
    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()
));

$console->run();

但是,当我运行 migrations:status 它输出:

C:\htdocs\bitvenda\app>php console.php migrations:status

  [Doctrine\DBAL\Migrations\MigrationException]
  Migrations namespace must be configured in order to use Doctrine migrations
  .

我做错了什么?

4

1 回答 1

10

正如@medina 评论的那样。我错过了配置文件。我创建了如下的 yml 配置文件:

name: Doctrine Migrations
migrations_namespace: DoctrineMigrations
table_name: doctrine_migration_versions
migrations_directory: /data/DoctrineMigrations

我将配置文件路径作为参数传递给它以使其工作。

php console.php migrations:status --configuration=config/migrations.yml

为了避免一直传递它,我将工作脚本目录更改为与配置文件相同的目录,以便学说迁移自动加载它

chdir(__DIR__.'/config');
于 2013-05-20T00:29:11.143 回答