phpdoctrine-ormdoctrinedoctrine-migrations

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 \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($container->get(\Doctrine\ORM\EntityManager::class));

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

<?php

require_once "app/bootstrap.php";

return \Doctrine\Migrations\DependencyFactory::fromEntityManager(
    new \Doctrine\Migrations\Configuration\Migration\PhpFile(BP . '/config/doctrine-migrations.php'),
    new \Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager($container->get(\Doctrine\ORM\EntityManager::class))
);

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

Argument #1 ($helperSet) must be of type Symfony\Component\Console\Helper\HelperSet, Doctrine\Migrations\DependencyFactory given

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

Best Regards, Mavis.


Solution

  • 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.