Laravel websocket

From event4u-app/agent-config · View interactive version

Laravel websocket is an AI agent skill from the GitHub repository event4u-app/agent-config. Use when building Laravel real-time features — Broadcasting events, ShouldBroadcast, private/presence channels, Echo client. For non-Laravel WebSockets, use the stack-native skill.

How to use this skill

Skill file

laravel-websocket

When to use

Use when implementing real-time features — WebSockets, Broadcasting, or persistent connections.

Do NOT use when:

Procedure: Create a broadcast event

Step 0: Inspect

  1. Check config/broadcasting.php for driver (Reverb, Pusher, Ably).
  2. Check existing broadcast events — match patterns.
  3. Check routes/channels.php for channel authorization.

Step 1: Create event class

  1. Implement ShouldBroadcast.
  2. Define broadcastOn() with appropriate channel type (public/private/presence).
  3. Define broadcastAs() for event name.
  4. Define broadcastWith() — small payload (IDs + changed fields only).

Step 2: Authorize channel

Add authorization in routes/channels.php for private/presence channels.

Step 3: Client setup

Use Laravel Echo to listen on the channel. Wire up reconnection with exponential backoff.

Conventions

→ See guideline php/websocket.md for broadcasting setup, channel types, connection management, Echo.

Validate

Output format

  1. Event class with broadcastOn() and channel definitions
  2. Client-side listener integration code

Gotcha

Do NOT

Auto-trigger keywords

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.