Php 条令迁移命名空间错误

Php 条令迁移命名空间错误,php,doctrine,silex,doctrine-migrations,Php,Doctrine,Silex,Doctrine Migrations,我正在尝试在silex框架之上设置条令迁移。我通过composer安装了它 "doctrine/dbal": "2.3.*", "doctrine/migrations": "dev-master", 我的控制台文件: ... $app['composer_loader']->add('Doctrine\DBAL\Migrations', __DIR__.'/../vendor/doctrine/migrations/lib/'); $helperSet = new \Symfony\

我正在尝试在silex框架之上设置条令迁移。我通过composer安装了它

"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();
但是,当我运行迁移:状态时,它会输出:

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

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

我做错了什么?

正如@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');

Dextervip,看看[这个其他问题][1],它可能会解决你的问题。[1] :@medina你说得对,我错过了。非常感谢。你们知道有并没有办法设置配置文件的默认路径?太好了!我注意到是你自己想出来的。。玩得开心