Real-time (Reverb / Echo)
Live chat messages and push notifications over WebSockets. This scaffold provides the Laravel-side broadcast event, the channel authorization, and the Echo listeners; the broadcaster itself (Laravel Reverb) is installed separately.
Real-time needs a running WebSocket server (
reverb:start). Unlike the other sections it isn't visible on a plainphp artisan serve— it degrades gracefully: with no broadcaster configured, the event simply doesn't broadcast and the app works normally.
Scaffold
php artisan adminlte:scaffold realtime
Publishes:
| Artifact | Destination |
|---|---|
NewChatMessage broadcast event |
app/Events/ |
| Echo listener bundle | resources/js/adminlte-realtime.js |
| Conversation channel authorization | appended to routes/channels.php (when present) |
Going live
-
Install broadcasting (choose Reverb) and set the
REVERB_*keys in.env:php artisan install:broadcasting -
Build the client (laravel-echo + the Reverb client are added by the step above):
npm install && npm run build -
Import the listeners from your Vite entry (after Echo is bootstrapped):
// resources/js/app.js import './adminlte-realtime' -
Broadcast on send — in
ChatController@store, after persisting the message:broadcast(new \App\Events\NewChatMessage($message))->toOthers(); -
Run the servers:
php artisan reverb:start php artisan queue:work # if the event implements ShouldBroadcast (queued)
How it works
NewChatMessagebroadcasts on the private channelconversation.{id}with a small payload (id,body,user_id,created_at).routes/channels.phpauthorizes a user on that channel only if they belong to the conversation.adminlte-realtime.jssubscribes the open conversation and dispatches a DOMadminlte:chat-messageevent your chat view can render; it also listens on Laravel'sApp.Models.User.{id}channel for broadcast notifications and dispatchesadminlte:notification.
All of it no-ops when window.Echo is absent, so the bundle is safe to ship even
before you finish the Reverb setup.