Closed7

Laravel 9 から Laravel 10 へバージョンupするスレ

TetoTetoTetoTeto

必須条件

  • PHP:8.1.0
  • Composer:2.2.0
  • Composer依存パッケージの更新
  • 最低安定度:stableに更新or項目削除

それぞれの環境が条件を満たしているか確認しておく

TetoTetoTetoTeto

その他の影響範囲

https://laravel.com/docs/10.x/upgrade#updating-dependencies

Laravel9 に続き、色々更新する必要がありそう

You should update the following dependencies in your application's composer.json file:

laravel/framework to ^10.0
laravel/sanctum to ^3.2
doctrine/dbal to ^3.0
spatie/laravel-ignition to ^2.0
laravel/passport to ^11.0 (Upgrade Guide)

TetoTetoTetoTeto

更新作業

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires fzaninotto/faker ^1.9.1 -> satisfiable by fzaninotto/faker[v1.9.1, v1.9.2].
    - fzaninotto/faker[v1.9.1, ..., v1.9.2] require php ^5.3.3 || ^7.0 -> your php version (8.1.7) does not satisfy that requirement.
  Problem 2
    - Conclusion: don't install fideloper/proxy 4.2.2 (conflict analysis result)
    - Conclusion: don't install fideloper/proxy 4.4.0 (conflict analysis result)
    - Conclusion: don't install fideloper/proxy 4.4.2 (conflict analysis result)
    - illuminate/contracts[v5.6.0, ..., v5.8.36] require php ^7.1.3 -> your php version (8.1.7) does not satisfy that requirement.
    - illuminate/contracts[v6.0.0, ..., v6.19.1] require php ^7.2 -> your php version (8.1.7) does not satisfy that requirement.
    - Root composer.json requires fideloper/proxy ^4.2 -> satisfiable by fideloper/proxy[4.2.0, ..., 4.4.2].

今回も依存関係の解消をしていく必要がありそう

メモ:Problemの解消で依存関係を確認するコマンド

/var/www/html # composer why illuminate/support
bensampo/laravel-enum   v6.7.0   requires illuminate/support (^9 || ^10)
laravel/framework       v9.52.16 replaces illuminate/support (self.version)
...
TetoTetoTetoTeto

パッケージの更新が完了したため実装の影響を確認

テストで修正がいくつか必要そう

Validate::makeメソッドのメッセージに関する仕様が変わったっぽい

# Laravel9
$validator = Validator::make($data_list, $rules);

# Laravel10
$validator = Validator::make($data_list, $rules, $request->messages());
TetoTetoTetoTeto

CIの実行時 larastanのパッケージ変更に伴うエラー
neonファイルを修正

CIも通ることを確認

E2Eテストも無事通ることを確認

まとめ

  • upgrade guideにとりあえず従う
  • composer update を実行し、依存関係のエラーが出る場合は依存先のpackage見ながら修正
  • 一通りテストが通るように修正
このスクラップは3ヶ月前にクローズされました