Why Upgrade to Laravel 13?
Laravel 13 brings several important improvements:
- PHP 8.3 Baseline — Faster performance and access to modern PHP features like typed class constants,
json_validate(), and the#[Override]attribute. - Leaner Core — Removal of redundant polyfills and backward-compatibility code means a lighter, faster framework.
- Symfony 7.4/8.0 Support — Updated Symfony components provide a more stable and future-proof foundation.
- New Cache::touch() Method — Extend a cache entry's TTL without re-fetching its value, which cuts unnecessary reads.
- Improved Queue Consistency — More predictable behavior across different queue drivers (database, Redis, SQS).
- Better Testing Utilities — Enhanced test isolation with automatic
Strfactory resets and other improvements. - Security Enhancements — Updated encryption primitives and dependency upgrades.
Before You Start
Make sure you have:
- PHP 8.3+ installed (this is the big one: Laravel 13 drops PHP 8.2 support)
- A database backup (always back up before major upgrades)
- A clean Git branch for the upgrade work
git checkout -b upgrade/laravel-13
Step 1: Update PHP
First, verify your PHP version:
php -v
If you're still on PHP 8.2, upgrade to 8.3 or later. On macOS with Homebrew:
brew install [email protected]
brew link [email protected]
On Ubuntu:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.3 php8.3-cli php8.3-mbstring php8.3-xml php8.3-curl php8.3-mysql php8.3-zip
Step 2: Update Composer Dependencies
The core of the upgrade is updating composer.json. Here are the key changes for our e-learning project:
Framework & First-Party Packages
{
"require": {
"php": "^8.3",
"laravel/breeze": "^2.3",
"laravel/framework": "^13.0",
"laravel/reverb": "^1.8",
"laravel/tinker": "^3.0",
"livewire/livewire": "^3.6.4",
"livewire/volt": "^1.7.0",
"maatwebsite/excel": "^3.1",
"spatie/laravel-permission": "^7.2"
}
}
The key changes are php (^8.2 → ^8.3), laravel/framework (^12.0 → ^13.0), laravel/reverb (^1.7 → ^1.8), and laravel/tinker (^2.10.1 → ^3.0). The dev dependencies stay the same because they're already compatible with Laravel 13.
Dev Dependencies
No changes needed. All packages (phpunit, collision, pint, sail, pail) are compatible with Laravel 13 at their current versions.
{
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.24",
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5.3"
}
}
Then run:
composer update laravel/framework laravel/reverb laravel/tinker -W
💡 Tip: If you encounter dependency conflicts, try
composer update --with-all-dependenciesto resolve them automatically.
Step 3: Review Configuration Changes
Laravel 13 may change some default configuration values. Compare your config files with the Laravel 13 laravel/laravel skeleton on GitHub. If your app is missing a config file you want to customize, publish it with:
php artisan config:publish
Key files to review:
config/app.php— Check for new default valuesconfig/cache.php— Newtouchmethod supportconfig/queue.php— Queue driver consistency changes
Step 4: Address Breaking Changes
Removed Polyfills
Laravel 13 removes backward-compatibility code for older PHP versions. If you were using any deprecated helpers, update them now.
PHPUnit
PHPUnit 11 still works for this project on Laravel 13, so you don't need to upgrade it yet. The official upgrade guide recommends phpunit/phpunit ^12.0, so when you move to PHPUnit 12, watch out for:
- Potentially removed deprecated assertions
- Stricter method signatures for
setUp()andtearDown()
Step 5: Update Frontend Dependencies
No frontend dependency changes are required:
npm install
npm run build
The existing laravel-vite-plugin (^2.0.0) and Vite (^7.0.7) work fine with Laravel 13.
Step 6: Test Everything
Run the full test suite to catch any issues:
php artisan test
For our e-learning platform, pay special attention to:
- Livewire component tests — Ensure all admin, teacher, and student components render correctly
- Real-time features — Test WebSocket connections with Laravel Reverb
- Excel import — Verify student import still works with Maatwebsite Excel
- Role-based access — Confirm Spatie Permission gates still function properly
Step 7: Adopt New Features
Once the upgrade is stable, consider adopting Laravel 13's new features:
Cache::touch()
This is a good fit for our exam session caching: extend the TTL without re-reading the value.
// In CBT exam: keep the session alive without re-fetching
Cache::touch("exam_session:{$studentId}:{$examId}", now()->addMinutes(30));
PHP 8.3 Features
Take advantage of PHP 8.3 in your codebase:
// Typed class constants
class ExamStatus
{
const string PENDING = 'pending';
const string ACTIVE = 'active';
const string COMPLETED = 'completed';
}
// json_validate() — No need for json_decode + error check
if (json_validate($submissionData)) {
// Process the submission
}
Step 8: Deploy to Production
Follow the standard deployment checklist, paying extra attention to the PHP version:
# Verify production PHP version
php -v # Must be 8.3+
# Pull and install
git pull origin main
composer install --no-dev --optimize-autoloader
npm install && npm run build
# Migrate and optimize
php artisan migrate --force
php artisan optimize
# Restart background services
sudo supervisorctl restart elearning-worker:*
sudo supervisorctl restart laravel-reverb
Summary
Upgrading from Laravel 12 to Laravel 13 for this e-learning project is relatively straightforward. The biggest prerequisite is making sure PHP 8.3+ is available. The actual code changes are minimal: mostly dependency version bumps, and PHPUnit stays on version 11.
| Area | Effort |
|---|---|
| PHP upgrade | 🟡 Medium (depends on hosting) |
| Composer dependencies | 🟢 Low (only 4 packages changed) |
| Code changes | 🟢 Low (minimal breaking changes) |
| Test fixes | 🟢 Low (PHPUnit unchanged) |
| Production deployment | 🟢 Low |
For most projects, you should be able to finish the upgrade in less than a day. Happy upgrading! 🚀
🔗 Resources:

Written by Muhammad Fari Madyan
Senior Backend Engineer and co-founder of LampungDev. I write up what I build so others can learn from it.
