Symfony 5.1.2 Unrecognized options “dir_name, namespace” under “doctrine_migrations”.

At my recent update from Symfony 5.1.0 to Symfony 5.1.2 I got surprised by this error message:

Unrecognized options "dir_name, namespace" under "doctrine_migrations". Available options are "all_or_nothing", "check_database_platform", "connection", "custom_template", "em", "migrations", "migrations_paths", "name", "organize_migrations", "services", "storage"

And it took me quite some time to find out what went wrong…

… since one should assume that a clean bugfix-update won’t produce such an error.

Well, the problem was, that I still hat doctrine installed as symfony/orm-pack, and within this pack the actual doctrine-modules are enclosed. And when I then executed

composer update symfony/* --with-all-dependencies

of course the symfony/orm-pack (and the enclosed doctrine-modules as well) was updated to the newest version… The problem with that is, that in the meantime doctrine 3.0 has been published and this version does not seem to be as compatible with the doctrine 2.x versions as it would be necessary to be to simply update it. Actually, you might expect such incompatabilities on a major version change.

The Solution

Via discussions on github with various suggested solutions – which all didn’t work for me – I came across this article Symfony 4: Unpack the Packs which – among other things – urged to “unpack” the originally oh so comfortable installed symfony/…-packs and by doing so replacing the symfony/…-pack with the original modules in the composer.json list.
This prevents any unintended updates of these modules, i.e. here the doctrine-modules

And, voila: a succeeding

composer update symfony/* --with-all-dependencies

updated everything smoothly.

Update

But the problem is still not 100% solved with that, since a simple

composer update

still produces the same error. The only remedy here is a manual intervention in the composer.json: the (still) unlimited version restriction for the doctrine bundles

        "doctrine/doctrine-bundle": "*",
        "doctrine/doctrine-migrations-bundle": "*",
        "doctrine/orm": "*",

has to be limited to version 2:

        "doctrine/doctrine-bundle": "~2",
        "doctrine/doctrine-migrations-bundle": "~2",
        "doctrine/orm": "~2",

The exact syntax explanation you can find in the composer documentation about versions and constraints.

Please, let me know if this helped you or how you got the problem under control.

P.S.: of course, this is also still true for all updates from “pre Symfony 5.1.2” to Symfony 5.1.3)

Dieser Beitrag ist auch verfügbar auf: German

1 thought on “Symfony 5.1.2 Unrecognized options “dir_name, namespace” under “doctrine_migrations”.”

  1. Oh, by the way, that really only affects projects that were set up before Symfony 5.1.2. Projects created with Symfony 5.1.2 or later work like a charm with Doctrine ^3

    Reply

Leave a Comment