7

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

我在同一个文件夹中有教义-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

在 /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
4

3 回答 3

1

您可以使用以下命令修改您的 composer.json:

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

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

composer update

最后,确保在 AppKernel.php 中启用包:

new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
于 2017-11-05T22:28:58.083 回答
0

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

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

./doctrine-migrations migrations:migrate
于 2013-08-08T14:29:10.250 回答
0

我对 symfony 3.4 也有同样的问题
我所有来自“/config/packages”的包配置文件都被 symfony 忽略了。

我通过编辑文件解决了这个问题:

app/config/config_dev.yml
imports:
    - { resource: config.yml }
    - { resource: '../../config/packages/dev/' } #added this line
app/config/config.yml
imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: '../../config/packages/doctrine.yaml' }
    - { resource: '../../config/packages/doctrine_migrations.yaml' }
    - { resource: '../../config/packages/fos_rest.yaml' }
    - { resource: '../../config/packages/jms_serializer.yaml' }
    - { resource: '../../config/packages/security_checker.yaml' }
    - { resource: '../../config/packages/sensio_framework_extra.yaml' }
    - { resource: '../../config/packages/swiftmailer.yaml' }

不幸的是,无法设置目录“../../config/packages/”中所有文件的导入,因为某些文件无法以这种方式导入。

于 2021-08-18T22:28:57.737 回答