The Complete Production SOP: How to Deploy and Run Laravel 11 Reverb High-Performance WebSocket Server in Autonomous AI Agents
Step-by-step SOP to install and run Laravel 11 Reverb in Codex, Claude Code, and Cursor. Configure Echo, ShouldBroadcast events, and authorization channels.
Technical Overview & Architectural Context
Autonomous coding agents frequently stumble when implementing real-time WebSocket broadcasting in Laravel 11. Typical failure modes include falling back to legacy third-party solutions (Pusher or laravel-websockets packages), misconfiguring CORS/host bindings in config/reverb.php, omitting BroadcastServiceProvider loading (which Laravel 11 streamlines), or improperly structuring Laravel Echo client connection parameters using hardcoded legacy Pusher endpoints. Without a deterministic SOP, LLMs also fail to wire up channel authorization logic in routes/channels.php, often skipping private channel authentication guards or forgetting to implement the ShouldBroadcast interface on Eloquent event dispatches. The 'laravel-11-reverb-websockets' skill binds the agent to strict first-party Reverb conventions: executing the consolidated artisan scaffolding, establishing deterministic channel authorizations, ensuring non-blocking event queuing, and matching Echo client-side configuration directly to Reverb's environment variables.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Skill Installation and SKILL.md Mounting
Mount the skill manifest into your project's agent directory to enforce deterministic broadcasting workflows.
Place the SKILL.md inside your workspace's .agents/skills/ directory or Cursor/Windsurf agent rule hierarchy. Autonomous agents will parse frontmatter triggers such as 'install laravel reverb' and 'laravel echo reverb connect', anchoring LLM generation to official Laravel 11 Reverb architecture.
mkdir -p .agents/skills/laravel-11-reverb-websockets && curl -fsSL https://askills.dev/api/skills/laravel-11-reverb-websockets/raw -o .agents/skills/laravel-11-reverb-websockets/SKILL.md---
name: "laravel-11-reverb-websockets"
description: "Deploy native, real-time WebSocket broadcasting in Laravel 11 using first-party Laravel Reverb."
metadata:
author: "Laravel"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "install laravel reverb"
- "laravel shouldbroadcast event"
- "laravel echo reverb connect"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: true
net_access: true
---Inject the SKILL.md into Cursor's .cursorrules or Windsurf's .windsurfrules via inclusion pointers to minimize total prompt token usage across conversational turns.
Ensure fs_write permissions cover routes/channels.php and config/reverb.php; restricted sandboxes may reject modifications to bootstrap/app.php.
Broadcasting Scaffolding & Environment Synchronization
Instruct the agent to install Laravel Reverb and synchronize environment broadcasting variables.
Laravel 11 simplifies broadcasting configuration via 'php artisan install:broadcasting'. The agent must execute this command, select Reverb when prompted, and ensure appropriate environment keys (REVERB_APP_ID, REVERB_APP_KEY, REVERB_APP_SECRET, REVERB_HOST, REVERB_PORT, REVERB_SCHEME) are written to .env and mirrored into Vite client env files without exposing secrets.
php artisan install:broadcasting --without-node-prompt && npm install --save-dev laravel-echo pusher-jsBROADCAST_CONNECTION=reverb
REVERB_APP_ID=849201
REVERB_APP_KEY=wsappkeylocaldev
REVERB_APP_SECRET=wsappsecretlocaldev
REVERB_HOST="127.0.0.1"
REVERB_PORT=8080
REVERB_SCHEME=http
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"Always ensure BROADCAST_CONNECTION=reverb rather than legacy BROADCAST_DRIVER=reverb, as Laravel 11 standardized configuration keys under config/broadcasting.php.
Failing to prefix client variables with VITE_ will prevent frontend bundles (Vue/React/Blade) from establishing connections to the Reverb daemon.
Event Dispatching and Private Channel Authorization
Create ShouldBroadcast events and register channel authorization logic in routes/channels.php.
Direct the autonomous agent to declare domain events implementing Illuminate\Contracts\Broadcasting\ShouldBroadcast (or ShouldBroadcastNow for immediate sync delivery). The agent must define broadcastOn() using PrivateChannel or PresenceChannel instances and map corresponding authorization callbacks in routes/channels.php.
php artisan make:event OrderShipped<?php
namespace App\Events;
use App\Models\Order;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class OrderShipped implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(public Order $order) {}
public function broadcastOn(): array
{
return [
new PrivateChannel('orders.' . $this->order->id),
];
}
public function broadcastWith(): array
{
return [
'order_id' => $this->order->id,
'status' => $this->order->status,
'shipped_at' => now()->toIso8601String(),
];
}
}Always define broadcastWith() explicitly to avoid leaking full Eloquent model attributes across unencrypted WebSocket payloads.
Forgetting to wrap route callbacks in routes/channels.php with boolean return checks results in silent 403 Forbidden responses during Echo client subscription.
Client-Side Echo Initialization & Integration Quality Gate
Configure Laravel Echo with Pusher protocol and verify end-to-end WebSocket communication.
The skill instructs the agent to configure resources/js/echo.js using pusher-js adapted for Reverb's HTTP/WS transport. Once configured, the agent must run linting, verify routes, and execute an artisan verification test ensuring Reverb binds to the designated host and port.
php artisan reverb:start --debug & REVERB_PID=$! && sleep 2 && kill $REVERB_PIDimport Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
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,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});Ensure enabledTransports is explicitly set to ['ws', 'wss'] to disable fallback polling and prevent socket timeout latency.
When developing behind Docker or reverse proxies, ensure wsPort matches the externally exposed container port, not the internal container bind.
Real-World Scenario: Real-Time Multi-Tenant Order Tracking with Laravel 11 Reverb
“Implement real-time order tracking for our Laravel 11 application using Laravel Reverb. Scaffold broadcasting, configure Laravel Echo in resources/js/echo.js, create an OrderStatusUpdated event on a private channel 'orders.{orderId}', and add channel authorization so only the order's owner can listen.”
Runtime Troubleshooting & Failure Modes
Root Cause: The Reverb daemon is either not running, listening on an incompatible host/port binding (e.g., binding to localhost instead of 0.0.0.0 in Docker/WSL), or REVERB_APP_KEY in .env does not match VITE_REVERB_APP_KEY in the frontend build bundle.
php artisan reverb:restart && npm run build
# If running in Docker/Vagrant, ensure config/reverb.php specifies host '0.0.0.0':
# REVERB_SERVER_HOST=0.0.0.0Root Cause: Laravel Echo cannot authenticate the private channel because routes/channels.php does not allow the currently authenticated user, or the CSRF token / session cookie is missing from the Echo authorizer request.
Broadcast::channel('orders.{orderId}', function ($user, $orderId) {
return (int) $user->id === (int) \App\Models\Order::findOrFail($orderId)->user_id;
});Frequently Asked Questions (Laravel 11 Reverb High-Performance WebSocket Server SOP)
Q:Can I use Laravel 11 Reverb High-Performance WebSocket Server across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification supported across all modern agent runtimes. Placing the file in your shared repository or agent skills directory allows Codex, Claude Code, Cursor, and Windsurf to deterministically scaffold and configure Reverb.
Q:How does Laravel 11 Reverb High-Performance WebSocket Server prevent context window overflow during long agent sessions?
By establishing concise procedural boundaries and deterministic validation gates rather than polluting system prompts with redundant rules. The agent receives exact artisan commands and configuration templates, avoiding recursive trial-and-error debugging loops.
Q:Does this skill require escalated root or container permissions?
No. It is audited with a security score of 98/100 and runs safely within workspace-scoped sandboxes. The skill only executes standard non-root artisan, composer, and npm commands inside your project root.
Ready to equip your autonomous agent with Laravel 11 Reverb High-Performance WebSocket Server?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.