Realtime WebSocket Notifications for Laravel
Trigger real-time WebSocket events from Laravel controllers, jobs, and queued tasks. Zero-dependency PHP SDK — no Guzzle, no Reverb, no Echo server to configure or maintain.
composer require apinator/apinator-php npm install @apinator/client Laravel's broadcast system is powerful but traditionally requires a separate WebSocket server — Laravel Reverb, Echo Server, or a Pusher subscription. Apinator gives you real-time WebSocket notifications from any Laravel controller, queued job, or listener with a simple API call. No additional server process, no Echo server to configure, and no infrastructure to manage.
Quick Start
How to add WebSocket notifications to Laravel
Add realtime features to your Laravel app in a few steps.
Install the PHP SDK
Add the server SDK via Composer. Zero dependencies — pure PHP 8.1+.
Initialize in a service provider
Register the Apinator client as a singleton in your Laravel service container.
Trigger WebSocket events from a controller
Publish real-time WebSocket events from any Laravel controller or queued job. All subscribed browser clients receive the notification instantly.
Add a WebSocket channel auth route
Create a POST route that authenticates private WebSocket channel subscriptions using HMAC-SHA256 signing.
Why Laravel
Built for Laravel developers
Zero Dependencies
Pure PHP 8.1+ — no Guzzle, no cURL wrappers. Uses native stream context for HTTP requests.
Service Container Ready
Register as a singleton and inject via constructor. Follows Laravel dependency injection conventions.
Queue Compatible
Trigger events from Laravel queued jobs, listeners, and scheduled tasks. Works anywhere PHP runs.
Webhook Verification
Verify incoming webhook signatures in middleware or controller. Replay attack protection built in.
How WebSocket notifications work in a Laravel application
Laravel's traditional broadcasting system — Laravel Echo combined with a WebSocket server like Reverb or the older Laravel Echo Server — requires running a persistent WebSocket process alongside your web application. This adds operational complexity: a separate server to deploy, monitor for crashes, scale independently, and keep in sync with your Laravel authentication.
Apinator removes this complexity. Your Laravel application calls the Apinator SDK from a controller, job, or listener — a single method call that publishes a real-time WebSocket event to all subscribed browser clients. Apinator's infrastructure maintains the persistent WebSocket connections. Your Laravel server stays stateless and doesn't hold any WebSocket connections, which simplifies horizontal scaling behind a load balancer.
The PHP SDK has zero dependencies and uses PHP's native stream contexts for HTTP requests — no Guzzle version to pin, no Composer conflicts, and no compatibility issues across PHP 8.1+ versions. It works equally well in controllers, Queued Jobs, Artisan commands, scheduled tasks, and Laravel Listeners.
Full Example
Full Example: Realtime WebSocket Notifications in a Laravel Controller
Complete WebSocket example: Laravel service provider setup, controller for triggering real-time events, auth route for private channels, and a JavaScript frontend.
Related Docs
Read the core WebSocket guides
Related Use Cases
Explore realtime use cases
Start building realtime Laravel apps
Completely free. No credit card. No catch.