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.

マイナー バージョン (中央の番号が変更されている場合) をアップグレードしている場合、下位互換性に関する大幅な変更は発生しません。詳細については、Symfony の下位互換性の約束を参照してください。

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:

マイナー バージョンをアップグレードするには、次の 2 つの手順があります。
  1. Update the Symfony library via Composer;
    Composer を介して Symfony ライブラリを更新します。
  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:

composer.json ファイルは、Symfony パッケージをパッチ バージョンにアップグレードできるように構成されています。しかし、新しいマイナーバージョンにアップグレードするには、symfony/ で始まる各ライブラリの横にあるバージョン制約を更新する必要があるでしょう。 Symfony 5.3 から 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:

composer.json ファイルには、更新する必要がある追加のブロックも必要です。
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:

次に、Composer を使用して新しいバージョンのライブラリをダウンロードします。
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:

依存関係エラーが発生した場合は、Symfony ライブラリの依存関係である他のライブラリもアップグレードする必要があることを意味している可能性があります。それを許可するには、 --with-all-dependencies フラグを渡します。
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.

これにより、symfony/* およびそれらのパッケージが依存するすべてのパッケージが更新されます。

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.

それでもうまくいかない場合は、composer.json ファイルで、新しい Symfony バージョンと互換性のないライブラリのバージョンが指定されている可能性があります。その場合、そのライブラリを composer.json で新しいバージョンに更新すると、問題が解決する場合があります。

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).

発生する可能性のある別の問題は、プロジェクトの依存関係をローカル コンピューターにインストールできるが、リモート サーバーにはインストールできないことです。これは通常、マシンごとに PHP のバージョンが異なる場合に発生します。解決策は、プラットフォーム構成オプションを「composer.json」ファイルに追加して、依存関係に許可されている最高の PHP バージョンを定義することです (サーバーの PHP バージョンに設定します)。

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:

残りのライブラリをアップグレードすることもできます。 composer.json でバージョン制約を適切に処理した場合は、次のコマンドを実行して安全に実行できます。
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.

yourcomposer.json (例: dev-master) に不特定のバージョン制約がある場合、これにより Symfony 以外のライブラリが後方互換性を損なう変更を含む新しいバージョンにアップグレードされる可能性があることに注意してください。

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.

Symfony のすべてのバージョンには、これらの変更を説明する Symfony ディレクトリに含まれる UPGRADE ファイル (UPGRADE-5.4.md など) が付属しています。ドキュメントの指示に従い、それに応じてコードを更新すれば、将来更新しても安全です。

These documents can also be found in the Symfony Repository.

これらのドキュメントは、Symfony リポジトリにもあります。

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:

Symfony Flex は、レシピのアップグレードに役立ついくつかのコマンドを提供します。開始する前に、作業中の無関係な変更をコミットしてください。

1.18

1.18

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

Recipes:update コマンドは 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.

レシピ:更新コマンドはスマートです: インストールしたときのレシピと最新バージョンのレシピの違いを調べます。次に、パッチを作成してアプリに適用します。競合がある場合は、通常の git 競合のように解決し、通常のようにコミットできます。