Symfony and Doctrine: Unrecognized options “dir_name, namespace” under “doctrine_migrations”.
Your current version of Symfony is 5.0 and your version of Doctrine Migrations Bundle is 2.* and you run
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".
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.
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).
composer update. You will receive the error. Don’t worry, we’ll fix it now.
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.
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
.envfiles in the root of your project.
- If you have testing bundle or PHPUnit installed in your project, then you’ll need to review
phpunit.xml.distfile 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
If everything is OK and no error is shown during verification, commit and push your changes. That’s it.