Copied!
Laravel
How to upgrade from Laravel 8 to 10 The comprehensive guide
Upgrade From Laravel 8 To 10.jpg
Shahroz Javed
Feb 05, 2024 . 45 views
 

Introduction:

Welcome to this quick guide, In the ever-evolving world of web development, staying up-to-date with the latest technologies and frameworks is crucial. Laravel, known for its elegant syntax and powerful features, is no exception. In this article, we'll guide you through the process of upgrading your Laravel 8 application to the shiny new Laravel 10, with a sprinkle of PHP 8.1 or greater. Let's get started.

 

Prerequisites:

If your composer version is less than 2.2.0 run the following command to upgrade it.

composer self-update
          

This command ensures that you're using the latest version of Composer, a key player in orchestrating Laravel's dependencies.

 

Upgrading dependencies:

In you composer.json upgrade the following core dependencies to laravel 10 compatibality. Additionally, ensure your third-party dependencies align with the latest standards.

// Remove
"fruitcake/laravel-cors": "^2.0",
"facade/ignition": "^2.5",

// Replace
"facade/ignition": "^2.5" // replace with "spatie/laravel-ignition": "^2.0"

// Update core
"php": ">=7.4.3 <=8.2.14",
"laravel/framework": "^10.43",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.7",
"laravel/sail": "^1.13",

// Update all third-party dependencies along with these
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.5",
"nunomaduro/collision": "^6.2",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ignition": "^2.0"            
          
 

A Kernel Transformation:

Open your kernel.php file and update the Cors middleware:

// Replace
\Fruitcake\Cors\HandleCors::class,

// With
\Illuminate\Http\Middleware\HandleCors::class,
          

This change ensures your CORS handling keeps up with Laravel's latest moves.

 

Stability is Key:

Set the minimum-stability to "stable" in your composer.json:

"minimum-stability": "stable",

This ensures that your project relies on stable packages, guaranteeing a reliable performance.

 

Composer update

with all the preparations done, let's take the center stage and run the following command:

composer update

This command executes the upgrade, fetching the latest versions of your dependencies and ensuring a seamless transition.

Conclusion:

that's it! You have successfully upgraded from laravel 8 to 10. Embrace the latest features, revel in the performance improvements.

13 Shares

Related Posts

Similar Posts