I'm always excited to take on new projects and collaborate with innovative minds.

Phone

+977 9846930428

Email

mr.kashyapsandesh@gmail.com

Website

https://sandeshghimire.info.np

Address

Butwal,Nepal

Social Links

Laravel 9.16 → Laravel 11 Migration Guide (with Reverb Broadcasting)

This document provides a complete overview of the migration process from Laravel 9.16 to Laravel 11, including the integration of Laravel Reverb for real-time WebSocket broadcasting.

Laravel 9.16 → Laravel 11 Migration Guide (with Reverb Broadcasting)

 

Completed Changes

1. Composer Dependencies Updated

  • PHP requirement updated to ^8.2
  • Laravel Framework updated to ^11.0
  • Added Laravel Reverb: laravel/reverb ^1.0
  • Laravel Sanctum updated to ^4.0
  • Doctrine DBAL updated to ^3.0
  • PHPUnit updated to ^11.0
  • Other dev tools updated for compatibility

2. Bootstrap Structure Migrated

  • Migrated bootstrap/app.php to the Laravel 11 fluent bootstrap API
  • Middleware definitions moved into bootstrap/app.php
  • Custom service providers registered inside bootstrap/app.php
    (Laravel 11 no longer uses config/app.phpproviders)

3. Configuration Updates

  • config/app.php → Removed manual provider registration
    (auto-discovery handles this)
  • config/broadcasting.php → Added Reverb config
  • phpunit.xml → Updated schema for PHPUnit 11

📋 Next Steps (Manual Actions Required)


Step 1: Update Dependencies

composer update

Review breaking changes if you use:

  • Doctrine DBAL (raw SQL)
  • Sanctum session/token handling
  • Packages not updated for Laravel 11

Step 2: Install Reverb

php artisan install:broadcasting

This will:

  • Install Reverb
  • Publish configuration
  • Inject new .env variables

Step 3: Add/Update .env Variables

BROADCAST_DRIVER=reverb

REVERB_APP_ID=your-app-id
REVERB_APP_KEY=your-app-key
REVERB_APP_SECRET=your-app-secret
REVERB_HOST=localhost
REVERB_PORT=8080
REVERB_SCHEME=http

Generate new keys:

php artisan reverb:install

Step 4: Optional — Remove RouteServiceProvider

Laravel 11 loads routes directly from bootstrap/app.php.

You may safely remove the provider only after confirming everything works.


Step 5: Clean Up Old Kernel Files (After Testing)

Once the system is stable:

❌ Remove (if unused):

  • app/Http/Kernel.php
  • app/Console/Kernel.php

Laravel 11 uses bootstrap config instead of Kernel classes.

Keep them until fully migrated.


Step 6: Move Scheduled Tasks

Move CRON jobs from old app/Console/Kernel.php to:

routes/console.php

use Illuminate\Support\Facades\Schedule;

Schedule::command('sync:exp_vid')->daily();
Schedule::command('provider:token')->everyThirtyMinutes();
Schedule::command('trips:cancel')->everyFifteenMinutes();
Schedule::command('sanctum:prune-expired --hours=24')->daily();

Schedule::command('delivery:send-reminders')
    ->everyFiveMinutes()
    ->withoutOverlapping()
    ->runInBackground();

Step 7: Test Reverb

Start the server:

php artisan reverb:start

Create test channel:

Broadcast::channel('test-channel', fn() => true);

Frontend using Laravel Echo:

import Echo from "laravel-echo";

window.Echo = new Echo({
    broadcaster: "reverb",
    key: import.meta.env.VITE_REVERB_APP_KEY,
    wsHost: import.meta.env.VITE_REVERB_HOST,
    wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
    wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
    forcedTLS: (import.meta.env.VITE_REVERB_SCHEME ?? "https") === "https",
    enabledTransports: ["ws", "wss"],
});

Frontend Environment Variables

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

🔍 Breaking Changes to Review

1. Doctrine DBAL 3.x

  • Column types changed
  • SQL builder changed
  • Raw queries may need updates

2. Laravel Sanctum 4.x

  • Token expiration behaves differently
  • SPA middleware changed

3. Middleware Registration

  • Now entirely defined in bootstrap/app.php

4. Service Providers

  • Auto-discovered by Laravel
  • Custom providers defined inside bootstrap config

🚀 Reverb Production Setup

1. Supervisor Configuration

/etc/supervisor/conf.d/reverb.conf
[program:reverb]
command=php /path/to/artisan reverb:start
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/path/to/logs/reverb.log

Reload Supervisor:

supervisorctl reread
supervisorctl update
supervisorctl restart reverb

2. HTTPS / WSS Environment

REVERB_SCHEME=https
REVERB_PORT=443

3. Nginx Reverse Proxy (WebSockets)

location /app/ {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;
}

🧪 Testing Checklist

  • Run composer update cleanly
  • Reverb installed & configured
  • .env updated
  • Reverb server running
  • Broadcast events working
  • Echo frontend connected
  • CRON jobs working via routes/console.php
  • Sanctum authentication validated
  • Database queries OK under DBAL 3.x
  • No deprecation warnings

🆘 Troubleshooting

Class 'App\Http\Kernel' not found

✔ Keep old Kernel files during transition.


❌ Reverb Connection Timeouts

  • Check firewall
  • Check SSL
  • Verify ports
  • Validate .env entries

❌ Broadcasting Not Working

  • Ensure BROADCAST_DRIVER=reverb
  • Ensure Reverb server is running
  • Check routes/channels.php authorization

If you want, I can also create:

✅ A PDF Migration Manual
✅ A blog version with headings + SEO
✅ A shortened version for GitHub README

Just tell me what format you prefer, my friend.

4 min read
Dec 05, 2025
By Sandesh Ghimire
Share

Leave a comment

Your email address will not be published. Required fields are marked *

Your experience on this site will be improved by allowing cookies. Cookie Policy