Hello Coders!! This article is about the Laravel Framework upgrade from older version 7.x to 8.x using laravel guide. So in this article, we are going to step by step we are going to upgrade laravel version from 7.x to 8.x.
If you have any existing laravel project in 7.x or older then you can upgrade the laravel version using these steps.
So, let’s get started. Currently, we are going to upgrade the essential required things and also pagination up-gradation at last.
So here is the command to check current laravel version
php artisan --version
Upgrade PHP version
So, first of all, you need to upgrade your php version to 7.3 or the latest in your system.
Change in composer.json file
So after that, we are going to open the composer.json file from the root directory and change the required versions there.
old composer.json file
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
"laravel/framework": "^7.29",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.0",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.3",
"phpunit/phpunit": "^8.5.8|^9.3.3"
},
Changed composer.json file
"require": {
"php": "^7.3",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.3.6",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0"
},
Here I have changed the “php”, “guzzlehttp/guzzle”, “laravel/framework”, “facade/ignition”, “nunomaduro/collision” and “phpunit/phpunit”. you can check in detail here.
The last step for Laravel Framework upgrade from older version 7.x to 8.x
Now we are going to run the composer update command so we can install these new dependencies.
composer update
This is it. This command will upgrade your project to latest laravel 8 framework.
Now additionally one more thing I am updating here is the pagination upgrade because the old one with the 7th version is no longer going to work with the 8th version and the pagination number will not visible.
Pagination Changes
So for the pagination implementation you just need to add this class in you controller file.
use Illuminate\Pagination\Paginator;
and call this method inside your controllers function.
Paginator::useBootstrap();
And you are Done !! pagination will also work with this change. You need to change inside every controller for this upgrade.
So this article shows you the path to Laravel Framework upgrade from older version 7.x to 8.x. you can check our other articles on laravel like this one Easy integration of Laravel 5.x Login With Google using socialite.