Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Reverb Laravel Package

laravel/reverb

Laravel Reverb adds real-time WebSocket support to Laravel applications, enabling event broadcasting and live updates via a first-party server. Designed to integrate with Laravel’s broadcasting features for fast, reliable real-time communication.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Reverb’s Role in Laravel Ecosystem: Designed as a drop-in replacement for Pusher, Reverb leverages Laravel’s broadcasting system (via BroadcastServiceProvider) and integrates seamlessly with Redis for pub/sub. This aligns perfectly with Laravel’s event-driven architecture, enabling real-time features (e.g., notifications, live updates) without external dependencies.
  • Protocol Compatibility: Supports WebSocket (WS/WSS) and Pusher’s HTTP API protocol, ensuring backward compatibility with existing Pusher-based clients. The X-Powered-By: Laravel Reverb header and Pusher-compatible auth signatures (e.g., BroadcastServiceProvider::boot()) reduce client-side refactoring.
  • Scalability Patterns: Built for horizontal scaling with Redis as the backbone. Features like connection pruning, activity timeouts, and reconnection logic (e.g., Redis auto-reconnect) mitigate single-point failures. The reload command (v1.6.3) enables zero-downtime updates.

Integration Feasibility

  • Laravel-Centric: Requires minimal setup—just install via Composer, publish configs (php artisan reverb:install), and configure Redis. The BroadcastServiceProvider handles routing automatically.
  • Redis Dependency: Mandatory for pub/sub. Existing Laravel apps using Redis for caching/sessions can reuse the same infrastructure.
  • Pusher Migration: Supports Pusher’s HTTP API (e.g., pusher:subscribe auth) via BroadcastServiceProvider::boot(), easing transitions from Pusher.
  • Customization: Extensible via:
    • Channel Managers: Override ArrayChannelManager for custom channel logic.
    • Middleware: Add auth/rate-limiting middleware (e.g., RateLimiter in v1.9.0).
    • Event Hooks: Dispatch events for channel/connection lifecycle (e.g., ChannelCreated).

Technical Risk

  • Redis Bottlenecks: High connection counts may strain Redis memory. Mitigate with:
    • Connection Limits: Configurable per-app (v1.6.0) or per-channel.
    • Scaling Mode: Redis clustering (though Reverb itself doesn’t manage this).
  • Protocol Quirks:
    • Pusher Compatibility: Some edge cases (e.g., presence channel encoding in v1.5.1) may require client adjustments.
    • Control Frames: Optional ping/pong via control frames (v1.4.2) may need tuning for high-latency networks.
  • State Management: Memory leaks (fixed in v1.7.0) and connection pruning events must be monitored during load testing.
  • PHP Versioning: PHP 8.5+ compatibility (v1.6.2) may require updates to older Laravel versions (e.g., <10.x).

Key Questions

  1. Redis Infrastructure:
    • Is Redis already in use? If not, what’s the budget for scaling (e.g., Redis Cluster vs. single node)?
    • Are connection limits (v1.6.0) sufficient, or will custom scaling logic be needed?
  2. Pusher Migration:
    • Are clients using Pusher’s HTTP API (e.g., pusher:subscribe)? If yes, verify auth signature compatibility (fixed in v1.8.1).
    • Will presence channels or private channels require client-side updates?
  3. Performance:
    • What’s the expected peak concurrent WebSocket connections? Stress-test Redis and Reverb’s O(N²) pub/sub merge (optimized in v1.10.1).
    • Are rate limits (v1.9.0) needed per channel/user?
  4. Observability:
    • How will connection pruning events (v1.1.0) be monitored?
    • Are there plans for custom metrics (e.g., message latency)?
  5. Deployment:
    • Will Reverb run alongside Laravel (shared process) or as a dedicated service (e.g., Docker)?
    • How will rolling updates be handled (e.g., reverb:reload command)?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Native integration with Laravel’s broadcasting system, events, and queues. Works alongside:
    • Redis: For pub/sub (required).
    • Laravel Echo: Client-side library for WebSocket management (supports Reverb out-of-the-box).
    • Horizon: For monitoring broadcast jobs (if using queues).
  • Tech Stack Compatibility:
    • PHP 8.1+: Required (PHP 8.5+ supported in v1.6.2).
    • Laravel 10+: Officially supported (backward compatibility for 9.x via laravel/echo).
    • Frontend: Compatible with JavaScript frameworks (Vue, React) via Laravel Echo or raw WebSocket clients.

Migration Path

  1. Assessment Phase:
    • Audit existing Pusher usage (HTTP API, channels, auth).
    • Benchmark Redis performance under expected load.
  2. Pilot Phase:
    • Non-Production: Deploy Reverb alongside Pusher (if using Pusher) to validate compatibility.
    • Feature Flag: Route a subset of channels to Reverb using Laravel’s shouldBroadcast() or middleware.
  3. Cutover Phase:
    • Config Update: Replace Pusher keys with Reverb’s BROADCAST_CONNECTION in .env:
      BROADCAST_CONNECTION=redis
      QUEUE_CONNECTION=redis
      
    • Client Update: Replace Pusher JS with Laravel Echo (if not already using it):
      import Echo from 'laravel-echo';
      window.Echo = new Echo({
        broadcaster: 'reverb',
        key: process.env.MIX_PUSHER_APP_KEY,
        wsHost: window.location.hostname,
        wsPort: 6001, // Default Reverb port
        forceTLS: window.location.protocol === 'https:',
      });
      
    • Auth Migration: Ensure BroadcastServiceProvider::boot() includes Pusher-compatible auth:
      Broadcast::route('private-channel.{id}', function ($user, $id) {
          return ['id' => $user->id]; // Pusher-compatible auth
      });
      
  4. Validation Phase:
    • Load Testing: Simulate peak traffic with tools like k6 or Artillery.
    • Monitoring: Track Redis memory, Reverb connection counts, and message latency.

Compatibility

Feature Compatibility Notes
Pusher HTTP API ✅ (v1.4.0+) Auth signatures match Pusher’s protocol.
Private Channels Uses Laravel’s auth callbacks.
Presence Channels ✅ (v1.5.1+) Fixed encoding to match Pusher.
Client Whispers ✅ (v1.8.0+) Restricted to channel members.
Rate Limiting ✅ (v1.9.0+) Per-channel or global limits.
Redis Clustering ⚠️ (Manual Setup) Reverb doesn’t auto-discover clusters; requires Redis config.
Laravel Echo Works with broadcaster: 'reverb'.
Custom Channels Extend ArrayChannelManager or use Channel::make().

Sequencing

  1. Infrastructure:
    • Deploy Redis cluster (if not already in use) with sufficient memory for connections.
    • Configure Reverb’s Redis connection in config/broadcasting.php:
      'connections' => [
          'redis' => [
              'driver' => 'redis',
              'connection' => 'cache', // or custom Redis config
              'options' => [
                  'cluster' => env('REDIS_CLUSTER', 'false'),
              ],
          ],
      ],
      
  2. Application:
    • Install Reverb:
      composer require laravel/reverb
      php artisan reverb:install
      
    • Update BroadcastServiceProvider to bind custom channels/middleware.
  3. Client-Side:
    • Update frontend to use Laravel Echo with Reverb’s endpoint (e.g., ws://app.test:6001).
  4. Testing:
    • Validate auth, presence channels, and edge cases (e.g., rapid reconnects).
  5. Monitoring:
    • Set up alerts for Redis memory usage and Reverb connection drops.

Operational Impact

Maintenance

  • Dependencies:
    • Redis: Critical for pub/sub. Monitor memory usage and replication lag.
    • PHP Extensions: Requires redis PHP extension (no additional extensions needed).
  • Updates:
    • Minor/Patch: Run composer update laravel/reverb and php artisan reverb:reload.
    • Major: Test thoroughly due to potential breaking changes (e.g.,
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony