Related Series
This article is a follow-up to the Laravel E-Learning Rebuild Series:
- Part 1: Introduction & Why I'm Upgrading
- Part 2: Setting Up Laravel 12 + Filament
- Part 3: Database Schema Design
- Part 4: Authentication & User Roles
- Part 5: Building the Exam System
- Part 6: Real-Time Features
- Part 7: Testing Strategy
- Part 8: Deployment
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 cache TTL without re-fetching values, reducing 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 backup 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 remain the same — 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:
rm -rf vendor composer.lock
composer install
💡 Tip: If you encounter dependency conflicts, try
composer update --with-all-dependenciesto resolve them automatically.
Step 3: Review Configuration Changes
Laravel 13 may update default configuration values. Compare your config files:
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 remains compatible with Laravel 13 — no forced upgrade needed. When PHPUnit 12 is released for Laravel packages, 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 perfectly 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()
Perfect for our exam session caching — extend the TTL without re-reading:
// 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 with extra attention to 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 laravel-queue:*
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 ensuring PHP 8.3+ is available. The actual code changes are minimal — mostly dependency version bumps and addressing any deprecated PHPUnit assertions.
| 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 |
The upgrade should be completable in less than a day for most projects. Happy upgrading! 🚀
🔗 Resources:

