Upgrading your laravel application to the latest version

Emmanuel Paul Mnzava.
3 min readMar 19, 2021

--

Are you in a situation where you have a laravel application that is of older version and you need to upgrade it?

Here is a step-by-step guide of how I go about upgrading a laravel application to the latest version.

Please note this guide is written when laravel is of version 8.33 and php is of version 8.0.

Laravel framework is divided into two.

  1. the core framework code which is maintained under this repository https://github.com/laravel/framework

2. The skeleton framework that utilizes the core framework maintained under this repository https://github.com/laravel/laravel

Both usually get updated from time to time and hence it's important to check on both of them when trying to make an upgrade.

So how is this done?

First of all, check your composer.json file on the required section as seen below

"require": {"php": "^7.2","epmnzava/bongolivesms-laravel": "^1.4","epmnzava/income-expense": "^1.0","laravel/framework": "^5.6","laravel/tinker": "^2.0","laravel/ui": "^2.1",}

Let's say my current application runs on PHP 7.2 and laravel version 5.6 as seen above

But the current laravel is 8.0 and PHP version is 8.0 as well what I will first do is change the section to below

New dependencies

"require": {"php": "^7.2|^8.0","epmnzava/bongolivesms-laravel": "^1.4","epmnzava/income-expense": "^1.0","laravel/framework": "^8.0","laravel/tinker": "^2.0","laravel/ui": "^2.1",}

The above dependency changes will allow my application to run on both php version 7.2 and 8.0 but also utilized the core code framework of laravel 8.0.

Step 2

You then need to delete the composer.lock file and run

composer update

The above command will download and update your current laravel core framework into the latest with all its dependencies but also update all other packages to the latest version.

However some of these packages, are not well maintained. I will cover how to use the packages of older versions in a separate article for now let's assume all is well. What's next?

Step 3

After you have finished step 2 go to the following page and read about some high impact changes that you need to make https://laravel.com/docs/8.x/upgrade depending on which version your upgrading there will be a few differences in the skeleton framework that you need to make the most common one is on the following files

boostrap/app.php

public/index.php

app/Exceptions/Handler.php

to quickly update these changes I suggest you create a different starter application of the current version then copy and paste the latest files of the code.

By following the above steps your application should be updated but notice this guide is to help you quickly update your application there may be a few files that need to be updated that have not been listed on this guide please don't forget to read the upgrade documentation that is available on the official laravel website.

Before you go… Thanks for reading the article! If you enjoyed it, please don’t forget to show your appreciation by clicking 👏 below!

Any questions or comments hit me up on

Mail: epmnzava@gmail.com

Twitter: https://twitter.com/epmnzava

Github: https://github.com/dbrax

--

--

Emmanuel Paul Mnzava.

Software Engineer and techprenuer with passion of helping entreprenuers and small businesses using Technology.