psr-container-doctrine icon indicating copy to clipboard operation
psr-container-doctrine copied to clipboard

Doctrine Migrations - Missing configuration in cli-config.php

Open thexpand opened this issue 4 years ago • 2 comments

The current documentation suggests the following configuration:

return new HelperSet(
    [
        'em' => new EntityManagerHelper(
            $container->get('doctrine.entity_manager.orm_default')
        ),
    ]
);

However, when I try to run php vendor/bin/doctrine-migrations migrations:status, it says that I have to provide a configuration for the database. The exact error is the following: You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrations.. Shouldn't we actually make it as follows?

/** @var EntityManagerInterface $entityManager */
$entityManager = $container->get('doctrine.entity_manager.orm_default');

return new HelperSet(
    [
        'em'            => new EntityManagerHelper(
            $entityManager
        ),
        'configuration' => new ConfigurationHelper(
            $entityManager->getConnection(),
            $container->get('doctrine.migrations.orm_default')
        ),
    ]
);

thexpand avatar Jun 28 '20 10:06 thexpand

I thought the 'em' key would suffice: is this a BC break in the upstram library? Similar to #27, I think we need to cement these with runnable examples: unit tests will just not cut it long-term.

Ocramius avatar Jun 28 '20 20:06 Ocramius

I don't think it's a BC break in the upstream library. Before I used the psr-container-doctrine implementation for the migrations, I had my own factory to create the configuration and I still needed this entry in the helper set, so I think it was always required.

thexpand avatar Jun 29 '20 07:06 thexpand