Upgrading from Laravel 12 to Laravel 13 ensures your application benefits from the latest features, performance improvements, bug fixes, and security updates.
Prerequisites
Before upgrading, make sure your environment meets the requirements:
- PHP 8.3 or higher
- Composer latest version
- Database backup completed
- Project files backed up
Check your current Laravel version:
php artisan --version
Step 1: Backup Your Application
Always create a backup of your project files and database before performing any major upgrade.
git add .
git commit -m "Backup before Laravel 13 upgrade"
Step 2: Update Composer Dependencies
Open your composer.json file and update Laravel:
"laravel/framework": "^13.0"
Update PHP requirement if needed:
"php": "^8.3"
Step 3: Update Packages
Update all dependencies:
composer update --with-all-dependencies
If you encounter dependency conflicts, update third-party packages to versions compatible with Laravel 13.
Step 4: Clear Application Cache
After the upgrade, clear all cached files:
php artisan optimize:clear
Step 5: Run Database Migrations
Execute any pending migrations:
php artisan migrate
Step 6: Rebuild Frontend Assets
If your project uses Vite:
npm install
npm run build
For development:
npm run dev
Step 7: Test Your Application
Verify that the following features work correctly:
- Authentication
- CRUD Operations
- Roles & Permissions
Run automated tests:
php artisan test
Step 8: Optimize for Production
Before deploying, optimize your application:
php artisan optimize
php artisan config:cache
php artisan route:cache
Verify the Upgrade
Confirm the new Laravel version:
php artisan --version
Expected output:
Laravel Framework 13.x
Conclusion
Upgrading from Laravel 12 to Laravel 13 is straightforward when you follow a structured process. Always back up your application, update dependencies carefully, test all features, and review any breaking changes before deploying to production. This ensures a smooth transition and keeps your application secure, modern, and maintainable.
