今更 Laravel 8 から Laravel 9 へバージョンupするスレ
upgrade guide に従い更新を行う
色々composer.jsonを書き直す必要がありそう
Composer Dependencies
You should update the following dependencies in your application's composer.json file:laravel/framework to ^9.0
nunomaduro/collision to ^6.1
In addition, please replace facade/ignition with "spatie/laravel-ignition": "^1.0" and pusher/pusher-php-server (if applicable) with "pusher/pusher-php-server": "^5.0" in your application's composer.json file.Furthermore, the following first-party packages have received new major releases to support Laravel 9.x. If applicable, you should read their individual upgrade guides before upgrading:
Vonage Notification Channel (v3.0) (Replaces Nexmo)
下記 package でエラー
Problem 1
- illuminate/contracts[v8.0.0, ..., v8.11.2] require php ^7.3 -> your php version (8.1.7) does not satisfy that requirement.
- Only one of these can be installed: illuminate/contracts[dev-master, v5.0.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev, v10.0.0, ..., 10.x-dev], laravel/framework[v9.0.0-beta.1, ..., 9.x-dev]. laravel/framework replaces illuminate/contracts and thus cannot coexist with it.
- bensampo/laravel-enum v4.2.0 requires illuminate/contracts ^8.0 -> satisfiable by illuminate/contracts[v8.0.0, ..., 8.x-dev].
- Root composer.json requires bensampo/laravel-enum ^4.2 -> satisfiable by bensampo/laravel-enum[v4.2.0].
- Root composer.json requires laravel/framework ^9.0 -> satisfiable by laravel/framework[v9.0.0-beta.1, ..., 9.x-dev].
依存する package一覧の確認
/var/www/html # composer why illuminate/contracts
bensampo/laravel-enum v4.2.0 requires illuminate/contracts (^8.0)
fideloper/proxy 4.4.2 requires illuminate/contracts (^5.0|^6.0|^7.0|^8.0|^9.0)
fruitcake/laravel-cors v2.2.0 requires illuminate/contracts (^6|^7|^8|^9)
laravel/framework v8.83.27 replaces illuminate/contracts (self.version)
laravel/socialite v5.11.0 requires illuminate/contracts (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0)
laravel/tinker v2.9.0 requires illuminate/contracts (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0)
nunomaduro/larastan 1.0.4 requires illuminate/contracts (^6.0 || ^7.0 || ^8.0 || ^9.0)
tymon/jwt-auth 1.0.x-dev requires illuminate/contracts (^5.2|^6|^7|^8|^9)
それぞれのpackageが対応するバージョンを調査する。
確認はPackagistというサイトが見やすいのでこちらで進める。
一通り packageの更新が完了したので 既存のテストを実行させる
→案の定こけた
ミドルウェアの更新が必要とのこと
テストも通ることを確認し、DEV環境にデプロイ
→するとCORSエラー
Laravel9に更新をすると Corsクラスのリプレイスが必要とのこと
Steps to upgrade:
Remove "fruitcake/laravel-cors" from your composer.json
Replace \Fruitcake\Cors\HandleCors::class, with \Illuminate\Http\Middleware\HandleCors::class, in app/Http/Kernel.php
最後にE2Eを一通り実行しシナリオが通ることを確認。
まとめ
- upgrade guideにとりあえず従う
- composer update を実行し、依存関係のエラーが出る場合は依存先のpackage見ながら修正
- 一通りテストが通るように修正