laravel/reverb
Laravel Reverb adds real-time WebSocket communication to Laravel apps. Use it to broadcast events and power live updates with a first-party, Laravel-native server. Official docs: https://laravel.com/docs/reverb
BroadcastServiceProvider, Event classes, and Channel implementations). This makes it ideal for applications requiring WebSocket-based real-time features (e.g., notifications, live updates, collaborative tools).redis, database).BroadcastAuth or custom middleware.composer require laravel/reverb and a single php artisan reverb:install command. Configuration is Laravel-centric (e.g., .env variables for Redis, app key, and server paths).ShouldBroadcast events, Channel classes, and BroadcastServiceProvider logic. No need to rewrite core broadcasting logic.laravel-echo, native mobile SDKs, or custom WebSocket libraries).| Risk Area | Assessment | Mitigation |
|---|---|---|
| Redis Dependency | Reverb requires Redis for pub/sub and state management. Downtime or misconfiguration can disrupt real-time features. | Use Redis clustering (sentinel/replication) and monitor Redis health via Laravel Horizon or Prometheus. |
| Scaling Complexity | Horizontal scaling requires careful Redis and Reverb instance coordination. Memory leaks (e.g., stale connections) can degrade performance. | Leverage Reverb’s built-in connection limits, activity timeouts, and Redis pub/sub optimizations. Monitor with tools like reverb:stats and adjust max_connections/timeout in config. |
| Authentication Overhead | Custom auth logic (e.g., JWT, API tokens) may require additional middleware or channel authorizers. | Reuse Laravel’s BroadcastAuth or extend ReverbAuthorization middleware. Test edge cases (e.g., token expiration, rate limiting). |
| Protocol Compatibility | Frontend clients must use Pusher-compatible WebSocket URLs (e.g., wss://app.example.com/app/reverb). Misconfigured paths can break connections. |
Validate server paths in .env (REVERB_SERVER_PATH) and test with wscat or Postman. |
| Legacy Laravel Versions | Officially supports Laravel 10–13. Older versions may require backports or manual fixes. | Pin to a stable release (e.g., v1.10.x) and test against your Laravel version. Use laravel/reverb:^1.0 for broader compatibility. |
| Rate Limiting | Rate limiting (added in v1.9+) requires configuration and may impact UX if overzealous. | Start with conservative limits (e.g., 100 messages/minute) and adjust based on monitoring. Use REVERB_RATE_LIMIT in .env. |
| Debugging Complexity | WebSocket issues (e.g., connection drops) can be harder to debug than HTTP. | Enable Reverb’s verbose logging (REVERB_LOG_LEVEL=debug) and use tools like reverb:reload for hot-reloading during development. |
Use Case Alignment:
Infrastructure Readiness:
Scaling Requirements:
Security & Compliance:
Team Expertise:
Cost vs. Pusher:
Alternatives:
beyondcode/laravel-websockets) or Pusher Lite suffice for simpler needs?upgrade and connection headers).| Phase | Steps | Tools/Commands |
|---|---|---|
| Preparation | 1. Audit existing broadcasting code (events, channels, auth). | php artisan route:list (check Broadcast routes), php artisan make:event. |
| 2. Set up Redis (cluster if HA needed). | docker-compose.yml (for local testing), redis-cli --scan --pattern "*". |
|
| 3. Backup existing Pusher credentials (if migrating). | .env backup. |
|
| Installation | 4. Install Reverb: composer require laravel/reverb. |
composer.json, composer.lock. |
5. Run installer: php artisan reverb:install. |
Generates config, publishes assets. | |
6. Configure .env: Update BROADCAST_DRIVER=redis, REVERB_* variables. |
.env, config/broadcasting.php. |
|
| Configuration | 7. Update BroadcastServiceProvider to use Reverb’s router. |
app/Providers/BroadcastServiceProvider.php. |
8. Configure channels/auth (e.g., App\Providers\RouteServiceProvider for private channels). |
routes/channels.php. |
|
| Testing | 9. Test locally with php artisan reverb:serve (dev) or php artisan reverb:start (prod). |
wscat -c wss://localhost/app/reverb, Laravel Echo test suite. |
| 10. Validate frontend integration (Laravel Echo). | npm run dev, Chrome DevTools (WebSocket tab). |
|
| Deployment | 11. Deploy Reverb as a service (e.g., systemd, Docker). | `systemctl start re |
How can I help you explore Laravel packages today?