Laravel Reverb
Reverb is a first-party WebSocket server for real-time Laravel applications.
// Install: composer require laravel/reverb
// Publish: php artisan reverb:install
// Start: php artisan reverb:start
// config/reverb.php
return [
"apps" => [
[
"app_id" => env("REVERB_APP_ID"),
"app_key" => env("REVERB_APP_KEY"),
"app_secret" => env("REVERB_APP_SECRET"),
"allowed_origins" => ["*"],
"ping_interval" => 30,
"max_message_size" => 10000,
],
],
];
// Broadcasting events
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class OrderShipped implements ShouldBroadcast
{
public function broadcastOn(): array
{
return [
new PrivateChannel("orders.{$this->order->id}"),
];
}
}Laravel Boost
Boost enables server-sent events (SSE), streaming responses, and progressive enhancement with Livewire.
// Install: composer require laravel/boost
// SSE Streaming
use Laravel\Boost\Facades\Boost;
Route::get("/stream", function () {
return Boost::stream(function () {
foreach (range(1, 5) as $i) {
Boost::send(["progress" => $i * 20]);
sleep(1);
}
Boost::send(["status" => "complete"]);
});
});
// Artisan progress bars with Boost
Boost::progress("Processing items...", $items, function ($item) {
$item->process();
});