- How do I install Laravel Reverb in my Laravel 11+ project?
- Run `composer require laravel/reverb` and execute `php artisan reverb:install`. This sets up the WebSocket server, configures Redis, and generates necessary files. Ensure your `.env` has `BROADCAST_DRIVER=redis` and `REVERB_ENABLED=true`.
- Does Laravel Reverb work with Laravel Echo and Pusher client SDKs?
- Yes, Reverb is fully compatible with Laravel Echo and Pusher’s JavaScript SDKs. Just point your frontend to `wss://your-app.test/app/reverb` (or your configured path) instead of Pusher’s endpoint. No frontend code changes are needed.
- What Laravel versions does Reverb officially support?
- Reverb supports Laravel 10, 11, 12, and 13. For older versions, use the `^1.0` branch or check the [Laravel docs](https://laravel.com/docs/reverb) for compatibility notes. Always pin to a stable release (e.g., `laravel/reverb:^1.10`) to avoid breaking changes.
- How do I secure Reverb for production? What about authentication?
- Reverb uses Laravel’s built-in `BroadcastAuth` for authentication. For custom auth (e.g., JWT), extend the `ReverbAuthorization` middleware or use channel authorizers. Always configure TLS (HTTPS/WSS) and set `REVERB_SERVER_PATH` to a secure endpoint. Rate limiting is configurable via `.env`.
- Can I use Reverb with Laravel Horizon for queue-based broadcasting?
- Yes, Reverb integrates with Laravel’s broadcasting queues. If you’re using `redis` as your broadcast driver, Horizon will process queued events for Reverb. Ensure your `config/broadcasting.php` is properly configured and Redis is running.
- What happens if Redis goes down? How do I monitor Reverb’s health?
- Reverb relies on Redis for pub/sub and connection state. If Redis fails, WebSocket connections will drop. Monitor Redis with tools like `reverb:stats` or Prometheus. Use Redis Sentinel for high availability. Reverb logs connection issues to `storage/logs/reverb.log` by default.
- How do I scale Reverb for high traffic or multiple servers?
- Reverb scales horizontally by running multiple instances behind a load balancer (e.g., Nginx). Use Redis clustering for pub/sub resilience. Configure `REVERB_MAX_CONNECTIONS` and `REVERB_CONNECTION_TIMEOUT` in `.env` to manage resource usage. Test with tools like `ab` or `k6` before deployment.
- Is there a way to test Reverb locally without deploying to production?
- Yes, use `php artisan reverb:serve` for local development. This starts a local WebSocket server on `ws://localhost:8080`. For testing, use `wscat` or Postman to simulate WebSocket connections. Mock Redis with a local instance or Docker for isolated testing.
- What are the alternatives to Laravel Reverb, and when should I consider them?
- Alternatives include Pusher, Ably, or self-hosted solutions like Socket.io. Use Reverb if you want a first-party, Laravel-native solution with minimal cost. Choose Pusher/Ably for managed services with global infrastructure. For lightweight needs, consider Server-Sent Events (SSE) via Laravel’s `Event::broadcast()` with `sse` driver.
- How do I debug WebSocket connection issues in Reverb?
- Enable debug logging with `REVERB_LOG_LEVEL=debug` in `.env`. Check `storage/logs/reverb.log` for errors. Use `reverb:reload` to restart the server without downtime. For frontend issues, verify the WebSocket URL matches your `.env` `REVERB_SERVER_PATH` and test with `wscat -c wss://your-app.test/app/reverb`.