Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • SensioLabs Professional services to help you with Symfony
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. Setup
  4. Upgrading a Minor Version (e.g. 5.0.0 to 5.1.0)
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • 1) Update the Symfony Library via Composer
    • Dependency Errors
    • Upgrading other Packages
  • 2) Updating your Code to Work with the new Version
  • 3) Updating Recipes

Upgrading a Minor Version (e.g. 5.0.0 to 5.1.0)

Edit this page

Upgrading a Minor Version (e.g. 5.0.0 to 5.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

The composer.json file is configured to allow Symfony packages to be upgraded to patch versions. But to upgrade to a new minor version, you will probably need to update the version constraint next to each library starting symfony/. Suppose you are upgrading from Symfony 5.3 to 5.4:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
      "...": "...",

      "require": {
-         "symfony/cache": "5.3.*",
+         "symfony/cache": "5.4.*",
-         "symfony/config": "5.3.*",
+         "symfony/config": "5.4.*",
-         "symfony/console": "5.3.*",
+         "symfony/console": "5.4.*",
          "...": "...",

          "...": "A few libraries starting with
                  symfony/ follow their own versioning scheme. You
                  do not need to update these versions: you can
                  upgrade them independently whenever you want",
          "symfony/monolog-bundle": "^3.5",
      },
      "...": "...",
  }

Your composer.json file should also have an extra block that you will also need to update:

1
2
3
4
5
6
7
"extra": {
      "symfony": {
          "...": "...",
-         "require": "5.3.*"
+         "require": "5.4.*"
      }
  }

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

1
$ composer update "symfony/*"

Dependency Errors

If you get a dependency error, it may mean that you also need to upgrade other libraries that are dependencies of the Symfony libraries. To allow that, pass the --with-all-dependencies flag:

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

This updates symfony/* and all packages that those packages depend on. By using tight version constraints in composer.json, you can control what versions each library upgrades to.

If this still doesn't work, your composer.json file may specify a version for a library that is not compatible with the newer Symfony version. In that case, updating that library to a newer version in composer.json may solve the issue.

Or, you may have deeper issues where different libraries depend on conflicting versions of other libraries. Check your error message to debug.

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

You may also want to upgrade the rest of your libraries. If you've done a good job with your version constraints in composer.json, you can do this safely by running:

1
$ composer update

Caution

Beware, if you have some unspecific version constraints in your composer.json (e.g. dev-master), this could upgrade some non-Symfony libraries to new versions that contain backwards-compatibility breaking changes.

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 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. UPGRADE-5.4.md) 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.

3) Updating Recipes

Over time - and especially when you upgrade to a new version of a library - an updated version of the recipe may be available. These updates are usually minor - e.g. new comments in a configuration file - but it's a good idea to keep your files in sync with the recipes.

Symfony Flex provides several commands to help upgrade your recipes. Be sure to commit any unrelated changes you're working on before starting:

1.18

The recipes:update command was introduced in Symfony Flex 1.18.

1
2
3
4
5
6
7
8
9
10
11
# choose an outdated recipe to update
$ composer recipes:update

# update a specific recipe
$ composer recipes:update symfony/framework-bundle

# see a list of all installed recipes and which have updates available
$ composer recipes

# see detailed information about a specific recipes
$ composer recipes symfony/framework-bundle

The recipes:update command is smart: it looks at the difference between the recipe when you installed it and the latest version. It then creates a patch and applies it to your app. If there are any conflicts, you can resolve them like a normal git conflict and commit like normal.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:

    Symfony 6.2 is backed by

    Symfony 6.2 is backed by

    The life jacket for your team and your project

    The life jacket for your team and your project

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of Ph3nol, a Symfony contributor

    Thanks Ph3nol for being a Symfony contributor

    1 commit • 8 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony