2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel6への移行

2
Posted at

弊社で稼働しているサービスを
Laravel5.8からLaravel6へ移行しました。

前提

一年前ほどから既存サービスをLaravelに徐々に移行中。
Laravelは月一くらいのペースで最新版に更新。

サイズ感

モデル数:89
コントローラ数:62

アップグレード

Upgrade Guide - Laravel - The PHP Framework For Web Artisans

composer

まずはcomposer.json

- "laravel/framework": "5.8.*"
+ "laravel/framework": "^6.0"

ただこれだけでは、composer installがすんなり行かず下記の対応

  • アップデート
    • appstract/laravel-opcache : "^2.0" → "^3.0"
    • hamburgscleanest/laravel-guzzle-throttle : "^3.0" → "^4.1"
  • 削除
    • beyondcode/laravel-query-detector : "@stable"
      • "^1.1"がリリースされていたのであとで復活しました

array_*とstr_*ヘルパーの除去

deprecatedになった時点で利用を辞めていましたが、それ以前に利用していたものがそれなりにありました。
地道にArr::*Str::*に置き換えました。

routeのパラメータ変更


Route::get('/profile/{location}', function ($location = null) {
    //
})->name('profile');

// Laravel 5.8: http://example.com/profile/active
echo route('profile', ['status' => 'active']);

// Laravel 6.0: http://example.com/profile?status=active
echo route('profile', ['status' => 'active']);

これ地味に痛かったです。
grepでrouteを全て抜き出して、5.8と6でそれぞれ結果を吐き出してdiffとりました。

予想通り一定数の違いがあったのでこちらも地道に修正。


Laravel6が出て様子見していましたがそろそろかと思いアップグレードしました。

Rails6がでて9日間でアップグレードしたGithubほどではありませんが、早めに移行できたかなと思います。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?