Doctrine迁移:“”命名空间中没有定义命令

时间:2013-06-08 21:35:10

标签: php doctrine migration

我正在尝试将Doctrine Migrations设置为独立程序,并且遇到了一些麻烦。

我在同一个文件夹中有doctrine-migrations.phar和migrations.yml。

migrations.yml包含以下内容:

name: Doctrine Sandbox Migrations
migrations_namespace: DoctrineMigrations
table_name: doctrine_migration_versions
migrations_directory: /home/myusername/myproject/Database/Update

Inside / home / myusername / myproject / Database / Update我有一个名为Version20130608161001.php的文件,其中包含以下内容:

namespace DoctrineMigrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

class Version20130608161001 extends AbstractMigration
{
    public function up(Schema $schema)
    {
        echo "Test";
    }

    public function down(Schema $schema)
    {

    }
}

当我运行命令时:

php doctrine-migrations.phar -v :migrate 

我收到以下错误消息:

[InvalidArgumentException]
There are no commands defined in the "" namespace.

Exception trace:
 () at phar:///home/myusername/Desktop/Doctrine/doctrine-migrations.phar/Symfony/Component/Console/Application.php:441
 Symfony\Component\Console\Application->findNamespace() at phar:///home/myusername/Desktop/Doctrine/doctrine-     migrations.phar/Symfony/Component/Console/Application.php:468
 Symfony\Component\Console\Application->findCommand() at phar:///home/myusername/Desktop/Doctrine/doctrine-migrations.phar/Symfony/Component/Console/Application.php:184
 Symfony\Component\Console\Application->doRun() at phar:///home/myusername/Desktop/Doctrine/doctrine-migrations.phar/Symfony/Component/Console/Application.php:113
 Symfony\Component\Console\Application->run() at /home/myusername/Desktop/Doctrine/doctrine-migrations.phar:59

2 个答案:

答案 0 :(得分:0)

刚遇到同样的问题......

您可以按如下方式运行命令:

./doctrine-migrations migrations:migrate

答案 1 :(得分:0)

您可以使用以下方法修改composer.json:

{
  "require": {
    "doctrine/doctrine-migrations-bundle": "dev-master"
  }
}

然后更新: *确保您在composer.json中拥有最新的SF稳定版本,此时此刻为3.3.0

composer update

最后,请务必在AppKernel.php中启用该包:

new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),