How to upgrade to Laravel 9

Published 11 January 2022 13:00 (3-minute read)

Every year, there is a new Laravel version. This year, it's Laravel 9. In this post, I describe how you can upgrade your Laravel 8 (or lower) application to Laravel 9.

When you want to upgrade your Laravel application to Laravel 9, take a look at the current version of your application. This checklist is made for applications running on Laravel 8 and wants to upgrade to Laravel 9. Other applications need to upgrade to Laravel 8 first.

Laravel 9: release date

Laravel 9 is released (February 8th, 2022)! The moment a new release is tagged, it will be available on GitHub. This release will be a new LTS (long-term support) release.

The estimated upgrade time is 30 minutes.

I suggest waiting a few days before upgrading your application to Laravel 9 to give external dependencies the time to upgrade/test the changes. In this Laravel 9 upgrade guide, I tried to explain everything in as much detail as possible.

Laravel 9: update check tool

Want to check if you can upgrade your Laravel project to the latest version (in this case, Laravel 9)? Copy your composer.json and paste it into the "Can I upgrade Laravel yet?" tool made by LaravelShift.

Steps to update Laravel 8 to 9

This year, the upgrade maybe take a bit longer. The expected upgrade time is 30 minutes, which is twice as long as the previous release.

1. High impact changes

There are 3 changes that may have a high impact on your application (upgrading) time. This is because of the new "Flysystem 3.0" & "Symfony Mailer" changes in the framework.

Laravel 9 requires PHP ^8.0.2, so it's time to prepare your server/packages for it!

Flysystem: "Flysystem powers all of the file manipulation methods provided by the Storage facade".

SwiftMailer to Symfony Mailer: SwiftMailer is no longer maintained as of December 2021.

2. Medium impact changes

There are 8 medium changes.

  • Belongs To Many firstOrNew, firstOrCreate, and updateOrCreate methods
  • Custom Casts & null
  • Default HTTP Client Timeout
  • PHP Return Types
  • Postgres "Schema" Configuration
  • The assertDeleted Method
  • The lang Directory
  • The password Rule
  • The when / unless Methods
  • Unvalidated Array Keys

Other upgrade tips

Here are some general tips to help you upgrade your Laravel projects to the latest version.

  1. Make use of LaravelShift, an automated way to upgrade your Laravel applications.
  2. Check other changes in the "laravel/laravel" project using the GitHub comparison tool.
  3. Spatie made the new exception handling view. Before it was `facade/ignition`, now it's a package from the company Spatie. You should change the "facade/ignition" in your composer.json to `"spatie/laravel-ignition": "^1.0"`

A big shoutout to the contributors to Laravel, and its packages!

Robin Dirksen
Robin Dirksen

Follow me on Twitter, there I post web-related content, tips/tricks, and other interesting things.

On my blog, you can find articles that I've found useful or wanted to share with anyone else.

If you want to know more about this article or just want to talk to me, don't hesitate to reach out.

Legal