James
James

Reputation: 680

Doctrine Migrations: There are no commands defined in the "" namespace

I'm trying to setup Doctrine Migrations as a standalone program and am having a little bit of trouble.

I have doctrine-migrations.phar and migrations.yml in the same folder.

migrations.yml contains the following:

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 I have a file called Version20130608161001.php which contains the following:

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)
    {

    }
}

When I run the command:

php doctrine-migrations.phar -v :migrate 

I get the following error message:

[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

Upvotes: 8

Views: 11020

Answers (3)

sertmo
sertmo

Reputation: 53

I have the same problems with symfony 3.4
All my package configuration files from "/config/packages" are ignored by symfony.

I fixed this by editing the files:

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' }

unfortunately it is not possible to set import of all the files in the directory "../../config/packages/" becaus some files cannot be imported in this way.

Upvotes: 0

JuliSmz
JuliSmz

Reputation: 1146

You can modify your composer.json with this:

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

And then update: *Ensure you have the latest SF stable version in composer.json, in this moment 3.3.0

composer update

Finally, be sure to enable the bundle in AppKernel.php:

new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),

Upvotes: 1

Alan Hollis
Alan Hollis

Reputation: 1322

Just had this same problem....

You can run the command as follows:

./doctrine-migrations migrations:migrate

Upvotes: 0

Related Questions