How To Upgrade From Laravel 8 To Laravel 9.

upgrade-to-9

Laravel 9 is now released, and we’re excited to check it out because it’s the most up-to-date technology available. So, let’s upgrade step by step.

I have been working on a personal e-commerce project in my spare time in Laravel 8 and I want to upgrade it to Laravel 9 and see what will happen. So that I can write the whole experience here on my website for guys.

For upgrading to 9.0 from 8.x we need to make sure that we have PHP 8.0.2 or greater as Laravel 9 requires it. we will update the dependencies via composer and we will test and fix the errors.

Updating Composer Dependencies

In fact, we need to update some dependencies in the composer.json in your project folder for upgrading to Laravel 9 as the following :

  • laravel/framework to ^9.0
  • nunomaduro/collision to ^6.1
  • facade/ignition to "spatie/laravel-ignition": "^1.0"
  • php to ^8.0

Then we will run the following command to upgrade:

composer update

Note: You can delete the composer.lock file, And, Composer will generate it again after the update.

I have faced one problem with a package that needs upgrade so what we should do is in this situation:

  • Go to the package page on Github and see the requirements.
  • At the right sidebar click on “Releases” then “Tags”
  • Get the release number and update the package on composer.json file.

You do an automated test or manual test for checking if everything working.