Skip to content
Advertisement

Doctrine ORM not working with the Migrations

Good Day, my friends.

I want to use the doctrine ORM with the Migrations.

The issue is next: I want to place the migration configuration file in the specific folder. For example: ‘config/doctrine-migrations.php’.

Everything working fine when I follow the official documentation and place the migrations.php file in the root folder, but when I try to place it in the specific folder system is not working.

My cli-config.php content is:

<?php

require_once "app/bootstrap.php";

return DoctrineORMToolsConsoleConsoleRunner::createHelperSet($container->get(DoctrineORMEntityManager::class));

Well, I can change this file in a next way:

<?php

require_once "app/bootstrap.php";

return DoctrineMigrationsDependencyFactory::fromEntityManager(
    new DoctrineMigrationsConfigurationMigrationPhpFile(BP . '/config/doctrine-migrations.php'),
    new DoctrineMigrationsConfigurationEntityManagerExistingEntityManager($container->get(DoctrineORMEntityManager::class))
);

After this, Doctrine Migration working fine, but Doctrine ORM stop working with the next error:

Argument #1 ($helperSet) must be of type SymfonyComponentConsoleHelperHelperSet, DoctrineMigrationsDependencyFactory given

If someone knows how to solve my issue and use a specific config file please clarify a possible solution.

Best Regards, Mavis.

Advertisement

Answer

Looks like I found an answer.

I can add custom integration in my application by this guide: https://www.doctrine-project.org/projects/doctrine-migrations/en/3.0/reference/custom-integration.html

In a custom file, I can configure whatever I want.

Hope that this solution will help somebody else.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement