Cover of the book Symfony 5: The Fast Track


Buy printed version

Upgrading a Minor Version (e.g. 4.0.0 to 4.1.0)

Upgrading a Minor Version (e.g. 4.0.0 to 4.1.0)

If you’re upgrading a minor version (where the middle number changes), then you should not encounter significant backward compatibility changes. For details, see the Symfony backward compatibility promise.

However, some backwards-compatibility breaks are possible and you’ll learn in a second how to prepare for them.

There are two steps to upgrading a minor version:

  1. Update the Symfony library via Composer;
  2. Update your code to work with the new version.

1) Update the Symfony Library via Composer

Your composer.json file should already be configured to allow your Symfony packages to be upgraded to minor versions. But, if a package was not upgraded, check that the version constrains of your Symfony dependencies are like this:

    "...": "...",

    "require": {
        "symfony/cache": "^4.0",
        "symfony/config": "^4.0",
        "symfony/console": "^4.0",
        "symfony/debug": "^4.0",
        "symfony/dependency-injection": "^4.0",
        "symfony/dotenv": "^4.0",
        "...": "..."
    "...": "...",

Next, use Composer to download new versions of the libraries:

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

Dependency Errors






Another issue that may happen is that the project dependencies can be installed on your local computer but not on the remote server. This usually happens when the PHP versions are different on each machine. The solution is to add the platform config option to your composer.json file to define the highest PHP version allowed for the dependencies (set it to the server’s PHP version).

Upgrading other Packages


$ composer update



2) Updating your Code to Work with the new Version

In theory, you should be done! However, you may need to make a few changes to your code to get everything working. Additionally, some features you’re using might still work, but might now be deprecated. While that’s just fine, if you know about these deprecations, you can start to fix them over time.

Every version of Symfony comes with an UPGRADE file (e.g. included in the Symfony directory that describes these changes. If you follow the instructions in the document and update your code accordingly, it should be safe to update in the future.

These documents can also be found in the Symfony Repository.
