paint-brush
How to Upgrade a Laravel App to the Latest Versionby@epmnzava
4,570 reads
4,570 reads

How to Upgrade a Laravel App to the Latest Version

by epmnzavaDecember 27th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A step-by-step guide of how to upgrade a laravel application to the latest version. The guide is written when the application is of version 8.33 and PHP 8.0. It's important to check on both of them when trying to make an upgrade. 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 lararvel website. You need to quickly update these changes then copy and paste the latest files of the code.

Company Mentioned

Mention Thumbnail
featured image - How to Upgrade a Laravel App to the Latest Version
epmnzava HackerNoon profile picture


Are you in a situation where you have a Laravel application that is of an 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?

Step 1

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 utilize 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. Depending on which version you’re 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 do not 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: [email protected]

Twitter: https://twitter.com/epmnzava

Github: https://github.com/dbrax