Upgrading or updating your Laravel application to a new version can bring in new features, improvements, and security enhancements. In this tutorial, you’ll learn how to upgrade or update Laravel versions 7, 8, and 9 to the latest Laravel 10 version using Composer command-line(cmd) tool.
How to Upgrade Laravel 8, 9 to 10 using CMD Composer
Steps to upgrade laravel version 8, 9 to 10 using cmd composer;
- Step 1: Update Composer
- Step 2: Update Laravel Dependencies
- Step 3: Update Configuration Files
- Step 4: Update Service Providers and Aliases
- Step 5: Update Routes and Middleware
- Step 6: Update Blade Views
- Step 7: Update Your Code
- Step 8: Run Artisan Commands
- Step 9: Test Your Application
- Step 10: Update Third-Party Packages
- Step 11: Backup and Rollback Plan
Step 1: Update Composer
First of all, open cmd or terminal, Before upgrading Laravel 8, 9, to 10, ensure that you have the latest version of Composer installed. Run the following command:
composer self-update
Step 2: Update Laravel Dependencies
Now, Open your terminal or cmd and navigate to your project’s root directory. Run the following commands to update your Laravel 7, 8, and 9 application’s dependencies to the latest versions compatible with Laravel 10:
composer require laravel/ui "^3.0" composer require laravel/framework "^10.0"
Step 3: Update Configuration Files
Laravel often introduces changes to configuration files between major versions. Compare your configuration directory with the new version’s configuration files, and make any necessary updates to your existing configuration files. Pay attention to files like app.php, auth.php, database.php etc.
Step 4: Update Service Providers and Aliases
Next, you need to check the config/app.php
file for any changes or additions to service providers and aliases. Update this file according to the Laravel 10 documentation.
Step 5: Update Routes and Middleware
Review your application’s root and middleware. Laravel occasionally removes or replaces certain routes or middleware in major releases. Update these as needed based on the Laravel 10 documentation.
Step 6: Update Blade Views
Inspect your blade view for any syntax or functionality changes that may be introduced in Laravel 10. Update these views accordingly.
Step 7: Update Your Code
Next, review your application’s code for any deprecated or changed functions, classes, or methods. Update your codebase as per Laravel 10 documentation.
Step 8: Run Artisan Commands
Once you have upgraded your laravel version. Now, you need to clear cache of laravel app. So, Run the following commands:
php artisan view:clear php artisan cache:clear php artisan route:cache php artisan config:cache php artisan optimize
Step 9: Test Your Application
Thoroughly test your application after the upgrade. Ensure that all functionality, routes, views, and third-party packages are working as expected.
Step 10: Update Third-Party Packages
If your application relies on third-party packages, make sure to update them to versions compatible with Laravel 10.
Step 11: Backup and Rollback Plan
Before deploying the upgraded laravel application to production, ensure you have a proper backup of laravel app and a rollback plan in case of unexpected issues.
Conclusion
That’s all; Throughout this tutorial, you have learned how to upgrade or update laravel 7, 8, 9 to 10 version.