2013-05-19 46 views
4

我試圖在silex框架上設置主義遷移。我通過作曲家安裝它。Doctrine Migrations命名空間錯誤

"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 
    . 

我做錯了嗎?

+1

Dextervip,採取[這個其他看看問題] [1],它可能會解決你的問題。 [1]:http://stackoverflow.com/questions/10620794/doctrine-migrations-2-zend-framework-2-is-it-possibile – medina

+0

@medina你說得對,我錯過了。謝謝。你知道是否有任何方法來設置配置文件的默認路徑? – dextervip

+0

太棒了!我已經注意到你自己想通了..玩得開心! =) – medina

回答

6

@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 

爲了避免通過這一切的時候,我換工作的腳本目錄相同的目錄作爲配置文件,以便學說遷移負載自動

​​