- How do I install Laravel Reverb in an existing Laravel project?
- Run `composer require laravel/reverb` and then execute `php artisan reverb:install` to publish the configuration and set up the service provider. Ensure Redis is configured in your `.env` file before proceeding. The package integrates automatically with Laravel’s broadcasting system.
- Does Laravel Reverb support Laravel 9.x or only Laravel 10+?
- Reverb is officially supported for Laravel 10+, but it can work with Laravel 9.x if you’re using Laravel Echo v1.13.0+ and PHP 8.1+. Check the [Laravel Echo compatibility docs](https://laravel.com/docs/echo) for specific version requirements. Some newer features may require Laravel 10.x.
- Can I migrate from Pusher to Reverb without changing client-side code?
- Yes, Reverb maintains Pusher’s HTTP API compatibility, including auth signatures and protocol behavior. Replace your Pusher app key with Reverb’s URL (e.g., `wss://your-app.test`) in Laravel Echo’s configuration. Presence and private channels may require minor client-side adjustments for encoding differences.
- What Redis setup is required for Laravel Reverb?
- Reverb requires Redis for pub/sub messaging. Use a single Redis instance for development, but for production, consider clustering or scaling horizontally to handle high connection loads. Configure Redis in your `.env` file with `BROADCAST_DRIVER=redis` and ensure the server supports WebSocket connections.
- How do I handle high WebSocket connection loads in production?
- Reverb includes connection pruning (auto-removal of inactive connections) and configurable limits per app/channel. For scaling, use Redis clustering or sharding. Monitor memory usage in Redis and adjust `reverb.connection_limits` in the config. Load-test with tools like `k6` to simulate peak traffic.
- Are there rate-limiting or security features built into Reverb?
- Yes, Reverb supports rate-limiting via middleware (introduced in v1.9.0). Configure limits in the `reverb.php` config under `rate_limits`. For security, use Laravel’s built-in auth middleware in channel classes or extend `ChannelManager` to enforce custom rules. Always validate WebSocket messages server-side.
- How do I deploy Laravel Reverb alongside Laravel in production?
- Reverb can run as a separate process (e.g., via Docker or systemd) or alongside Laravel using `php artisan reverb:start`. For zero-downtime updates, use `php artisan reverb:reload` to gracefully restart the server. Ensure Redis is highly available to avoid disruptions during updates.
- What alternatives exist to Laravel Reverb for WebSocket broadcasting?
- Alternatives include Pusher (paid), Ably (scalable but proprietary), or self-hosted solutions like Socket.io with Redis. Reverb stands out for its native Laravel integration, no vendor lock-in, and cost-effectiveness for self-hosted setups. For open-source options, consider `beyondcode/laravel-websockets` (though it’s less actively maintained).
- How do I monitor Reverb’s performance and connection health?
- Reverb emits events for connection pruning, channel activity, and errors. Log these events using Laravel’s logging system or forward them to monitoring tools like Sentry or Datadog. For metrics, extend the `ReverbServiceProvider` to publish custom stats or use Redis’s built-in monitoring tools like `redis-cli --stat`.
- Can I customize Reverb’s WebSocket behavior, like adding custom headers or protocols?
- Yes, Reverb allows customization via middleware and channel managers. Extend the `ChannelManager` to modify connection logic or add middleware to the `Reverb` facade for request/response filtering. For protocols, Reverb supports WebSocket (WS/WSS) and Pusher’s HTTP API by default, but custom protocols require low-level adjustments to the underlying `Ratchet` or `ReactPHP` components.