DEV Community

Nikola Stojiljkovic
Nikola Stojiljkovic

Posted on

Symfony and Doctrine: Unrecognized options “dir_name, namespace” under “doctrine_migrations”.

Problem

Your current version of Symfony is 5.0 and your version of Doctrine Migrations Bundle is 2.* and you run composer update
You will most likely get the following error when trying to update composer packages:

Unrecognized options "dir_name, namespace" under "doctrine_migrations". Available options are "all_or_nothing", "check_database_platform", "connection", "custom_template", "em", "factories", "migrations", "migrations_paths", "organize_migrations", "services", "storage".
Enter fullscreen mode Exit fullscreen mode

This happens because the format of the Symfony configuration files (located in the config directory of your project) changed and both package and Symfony maintainers haven’t bothered to create a proper update payload. The main problem is in the Doctrine Migrations Bundle upgrade from version 2.* to version 3.*. So, you’re now stuck with phased out configuration file formats.

Solution

This may not be the best solution, but it works. To resolve this, follow these steps:

  • Make sure your git branch is clear (everything is committed).
  • Run composer update. You will receive the error. Don’t worry, we’ll fix it now.
  • Run composer recipes:install --force -v. The output of this command will list all modified files, but you can also see which files have been modified by using Git.
  • Run composer install.

When recipes are forcefully installed, several Symfony configuration files are going to be updated to follow the standard of the latest version of packages. But that also means that they will be reverted to their default versions. This means that all of the changes which you made yourself in these configuration files will be rolled back (deleted) from the configuration files. To resolve this, use your favorite Git GUI tool (the built-in Git support for PHPStorm should be enough), review each of the modified Symfony configuration files and roll back lost pieces of code. Just make sure that you re-create only entries which you (previously) wrote yourself and leave the updated default configuration generated by Symfony (because that was the whole point of upgrading recipes in the first place).

The files which you’ll need to review are:

  • All edited files in the config directory.
  • All .env files in the root of your project.
  • .gitignore file.
  • If you have testing bundle or PHPUnit installed in your project, then you’ll need to review phpunit.xml.dist file as well.

When you’re done editing all modified configuration files, verify that everything is working properly with php bin/console cache:clear or (alternatively) by running composer install.

If everything is OK and no error is shown during verification, commit and push your changes. That’s it.

Top comments (0)