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.
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.
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.
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?
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:
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:
Twitter:
Github: