Laravel 12 has landed, bringing exciting new features, performance improvements, and breaking changes. If you’re maintaining a Laravel 10 or older application and planning to upgrade, this guide will help you transition smoothly without breaking your existing codebase.
Why Upgrade to Laravel 12?
Laravel 12 introduces several improvements:
- PHP 8.2+ requirement
- Native typed enums in route model binding
- Improved
Eloquentperformance - Slimmed-down default application skeleton
- Updated job batching and queue handling
- Security updates and deprecations removed
Let’s walk through how to upgrade your Laravel application to version 12.
Step 1: Check Your Current Laravel Version
First, confirm your existing Laravel version:
php artisan --version
If you’re on Laravel 10 or 11, the upgrade process is more straightforward. If you’re still on Laravel 9 or earlier, you’ll need to gradually upgrade to Laravel 10 first due to breaking changes in intermediate versions.
Step 2: Review Laravel 12 Upgrade Guide
Always start by reviewing the official Laravel Upgrade Guide for any version-specific notes and breaking changes. Pay special attention to:
- Removed functionality
- Changed method signatures
- Package compatibility
Step 3: Update composer.json
You should update the following dependencies in your application’s composer.json file:
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"phpunit/phpunit": "^11.0",
"pestphp/pest": "^3.0"
}
Step 4: Run composer update
After modifying your composer.json, run:
composer update
Make sure there are no dependency conflicts. If any packages are not compatible with Laravel 12, check for updated versions or alternatives.
Step 5: Check for Deprecated or Removed Features
Review the changelog or run a deprecation scan using tools like:
- Static analyzers like
phpstanorlarastan
Common breaking changes:
- Middleware behavior changes
- Changed method names (e.g.,
Carbon::now()usage) - Blade directives updates
- Event dispatching logic
Step 6: Run Tests
If your project has test coverage (you do have tests, right?), now’s the time to run them:
php artisan test
Or use PHPUnit:
vendor/bin/phpunit
Make sure to fix any failed tests caused by API changes or deprecated features.
Step 7: Update Frontend Dependencies (Optional)
If you’re using Laravel Mix or Vite, update the relevant packages in package.json. Also update Node, npm, and any front-end frameworks you rely on:
npm install
npm run dev
Step 8: Test the App Thoroughly
Manually test your app and ensure all major workflows work as expected:
- Authentication
- CRUD operations
- Jobs, queues, events
- API responses
- Scheduled tasks
Final Thoughts
Upgrading to Laravel 12 ensures your application remains secure, maintainable, and up-to-date with modern PHP practices. Although upgrades can be intimidating, following the official docs and breaking changes will help you avoid surprises.
If you’re dealing with a legacy app, consider using tools like Laravel Shift to automate some upgrade steps.
What’s Your Experience?
Have you already upgraded to Laravel 12? What challenges did you face? Share your experience in the comments — and don’t forget to give this post a 👏 if it helped!
Free resources for this topic
Code snippets and fixes for this topic
Get one practical tip every week
New tutorials, fixes and free cheat sheets from DEV Talk, straight to your inbox. No spam, unsubscribe in one click.
Free download: Laravel interview questions (PDF)
Have a question about this post?
Ask the community: other developers and the author can answer.
Get notified about new articles
One click, no email needed. Turn it off anytime with the bell at the top.
Get new articles on your iPhone
Add DEV Talk to your Home Screen, open it, then tap the bell.
Enjoying the content?
If this article helped you, you can support the author with a coffee. It keeps new posts coming.
Comments 0
No comments yet
Be the first to share your thoughts.