PHPackages                             blax-software/laravel-websockets - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. blax-software/laravel-websockets

ActiveLibrary[HTTP &amp; Networking](/categories/http)

blax-software/laravel-websockets
================================

An easy to launch a Pusher-compatible WebSockets server for Laravel.

1.14.1(2y ago)2233MITPHPPHP ^7.2|^8.0

Since Nov 25Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/blax-software/laravel-websockets)[ Packagist](https://packagist.org/packages/blax-software/laravel-websockets)[ Docs](https://github.com/beyondcode/laravel-websockets)[ RSS](/packages/blax-software-laravel-websockets/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (16)Versions (75)Used By (0)

[![Blax Software OSS](https://raw.githubusercontent.com/blax-software/laravel-workkit/master/art/oss-initiative-banner.svg)](https://github.com/blax-software)

Laravel WebSockets
==================

[](#laravel-websockets)

[![PHP Version](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](https://php.net)[![Laravel](https://camo.githubusercontent.com/7368f99d085dbbf9427a12a968ccf661c64eaacb5879be697f5bb8b2c6efbf44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d392e782d2d31322e782d6f72616e6765)](https://laravel.com)

Plug-and-play WebSockets for Laravel with a Pusher-compatible protocol, async fork-based handling, attribute-driven routing, and live operational tooling.

Note

This package is actively maintained as a fork of beyondcode/laravel-websockets.

Features
--------

[](#features)

- **`#[Websocket]` attribute on regular HTTP controllers** — turn any controller method into a WebSocket-callable endpoint with one annotation, no second class to maintain
- **Async processing** — incoming messages are handled in `pcntl_fork` child processes, so a slow handler never blocks the event loop
- **Broadcast from anywhere** — `ws_broadcast()`, `ws_whisper()`, `ws_broadcast_except()` helpers and a static `WebsocketService` API let any controller, job, or service push events to any channel
- **Multiple channel types** — public, `private-*`, `presence-*`, and `open-presence-*` channels with the standard auth handshake
- **Live ops tooling** — `php artisan websockets:watch` renders connection counts, authenticated users, and per-channel connections, refreshing every second:

    ```
    WebSocket Server — Live Stats
    2026-05-05 14:33:35 — refreshing every 1s (Ctrl+C to exit)

      Live Stats .......................................................................................................................................
      Total connections ............................................................................................................................. 12
      Authenticated users ............................................................................................................................ 3
      Active channels ................................................................................................................................ 1

    +-----------+-------------+
    | Channel   | Connections |
    +-----------+-------------+
    | websocket | 12          |
    +-----------+-------------+

    ```
- **Automatic route recognition** — controller class and method names map to event names automatically (`FlightschoolController::index` → `flightschool.index`); override per method or per class via `#[Websocket(event: ..., prefix: ..., suffix: ..., needAuth: true)]`
- **Hot code reload in dev, OPcache in prod** — `websocket:steer cache:clear` clears OPcache and the controller resolver cache without restarting the running server, so iteration is instant in development while production runs with fully warmed caches
- **Pusher-compatible protocol** — supports both modern `websocket.*` and legacy `pusher:*` action formats, drop-in for Echo and pusher-js clients
- **Test helpers** — `newConnection()`, `newActiveConnection()`, `newPrivateConnection()`, `newPresenceConnection()`, plus `assertSentEvent()` keep WebSocket tests short

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 9, 10, 11 or 12
- `ext-pcntl` (for async fork-based handling)

Installation
------------

[](#installation)

```
composer require blax-software/laravel-websockets
```

Publish the config:

```
php artisan vendor:publish --provider="BlaxSoftware\LaravelWebSockets\WebSocketsServiceProvider" --tag="config"
```

Start the server:

```
php artisan websockets:serve
```

Default URL is `ws://127.0.0.1:6001`.

Quick Start
-----------

[](#quick-start)

### 1. Mark a regular controller method as WebSocket-reachable

[](#1-mark-a-regular-controller-method-as-websocket-reachable)

```
use BlaxSoftware\LaravelWebSockets\Attributes\Websocket;

class FlightschoolController extends Controller
{
    #[Websocket]                      // event: "flightschool.index"
    public function index() { ... }

    #[Websocket(event: 'flightschools.list')]   // explicit override
    public function list() { ... }

    #[Websocket(needAuth: true)]      // requires authenticated socket
    public function update() { ... }
}
```

### 2. Broadcast from anywhere

[](#2-broadcast-from-anywhere)

```
// Helpers
ws_broadcast('chat.message', ['text' => 'Hello'], 'chat');
ws_whisper('chat.typing', ['typing' => true], ['1234.1', '1234.2'], 'chat');
ws_broadcast_except('chat.message', ['text' => 'Server msg'], ['1234.1'], 'chat');

// Service API
use BlaxSoftware\LaravelWebSockets\Services\WebsocketService;

WebsocketService::send('metrics.tick', ['count' => 1], 'websocket');
WebsocketService::broadcastExcept('chat.message', ['text' => 'Hi'], ['1234.1'], 'chat');
```

### 3. Build a private/presence auth payload

[](#3-build-a-privatepresence-auth-payload)

```
$auth = wsSession('private-updates', [
    'user_id'   => 7,
    'user_info' => ['name' => 'Jane'],
]);
```

### 4. Watch live stats

[](#4-watch-live-stats)

```
php artisan websockets:watch          # connection counts and channels
php artisan websockets:watch -v       # expanded per-connection rows
php artisan websockets:info           # one-shot snapshot
```

### 5. Iterate without restarting

[](#5-iterate-without-restarting)

```
php artisan websocket:steer cache:clear   # clear OPcache + resolver cache
php artisan websockets:restart            # graceful restart
php artisan websocket:restart-hard        # signal-based force restart
```

Channel Types
-------------

[](#channel-types)

TypePrefixDescriptionPublic*(none)*Anyone can subscribePrivate`private-`Server-signed auth requiredPresence`presence-`Auth required, tracks user list, broadcasts join/leaveOpen Presence`open-presence-`Presence semantics without the auth signature — useful for guestsTesting
-------

[](#testing)

```
$connection = $this->newActiveConnection(['chat']);

$this->wsHandler->onMessage($connection, new Message([
    'event' => 'websocket.ping',
    'data'  => new stdClass(),
]));

$connection->assertSentEvent('websocket.pong');
```

```
vendor/bin/phpunit --exclude-group=stability,stress,integration,requires-server
```

Documentation
-------------

[](#documentation)

- Main docs: [docs](docs)
- Getting started: [docs/getting-started/introduction.md](docs/getting-started/introduction.md)
- Helper &amp; testing guide: [docs/advanced-usage/helpers-and-testing.md](docs/advanced-usage/helpers-and-testing.md)
- Custom handlers: [docs/advanced-usage/custom-websocket-handlers.md](docs/advanced-usage/custom-websocket-handlers.md)

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md).

Security
--------

[](#security)

Please report vulnerabilities via the issue tracker or by email: .

Credits
-------

[](#credits)

- [Marcel Pociot](https://github.com/mpociot)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. See [LICENSE.md](LICENSE.md).

Star History
------------

[](#star-history)

[    ![Star History Chart](https://camo.githubusercontent.com/45921b7266a1946d3c230b64c7d3a6cefcb646c6c35143070599f1f007b17fc7/68747470733a2f2f6170692e737461722d686973746f72792e636f6d2f63686172743f7265706f733d626c61782d736f6674776172652f6c61726176656c2d776562736f636b65747326747970653d64617465266c6567656e643d746f702d6c656674) ](https://www.star-history.com/?repos=blax-software%2Flaravel-websockets&type=date&legend=top-left)

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance58

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~85 days

Total

69

Last Release

1039d ago

Major Versions

1.9.0 → 2.0.0-beta.292020-10-18

1.10.0 → 2.0.0-beta.332021-02-24

1.11.1 → 2.0.0-beta.342021-03-30

1.12.0 → 2.0.0-beta.362021-04-06

1.13.1 → 2.x-dev2022-09-21

PHP version history (4 changes)1.0.0PHP ^7.1

1.4.0PHP ^7.2

1.11.0PHP ^7.2|^8.0

2.x-devPHP ^8.0|^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d548acfc3520e2f810e35cfb78230f885befda9fa26a3be42353723c48f991e?d=identicon)[blax-software](/maintainers/blax-software)

---

Top Contributors

[![rennokki](https://avatars.githubusercontent.com/u/21983456?v=4)](https://github.com/rennokki "rennokki (412 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (206 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (200 commits)")[![justsomexanda](https://avatars.githubusercontent.com/u/48434066?v=4)](https://github.com/justsomexanda "justsomexanda (64 commits)")[![francislavoie](https://avatars.githubusercontent.com/u/2111701?v=4)](https://github.com/francislavoie "francislavoie (26 commits)")[![lionslair](https://avatars.githubusercontent.com/u/832259?v=4)](https://github.com/lionslair "lionslair (13 commits)")[![stayallive](https://avatars.githubusercontent.com/u/1090754?v=4)](https://github.com/stayallive "stayallive (12 commits)")[![anthonyvancauwenberghe](https://avatars.githubusercontent.com/u/7100315?v=4)](https://github.com/anthonyvancauwenberghe "anthonyvancauwenberghe (10 commits)")[![robindrost](https://avatars.githubusercontent.com/u/588012?v=4)](https://github.com/robindrost "robindrost (6 commits)")[![LKaemmerling](https://avatars.githubusercontent.com/u/4281581?v=4)](https://github.com/LKaemmerling "LKaemmerling (4 commits)")[![erlangparasu](https://avatars.githubusercontent.com/u/20636828?v=4)](https://github.com/erlangparasu "erlangparasu (3 commits)")[![kloining](https://avatars.githubusercontent.com/u/8821225?v=4)](https://github.com/kloining "kloining (3 commits)")[![simonbuehler](https://avatars.githubusercontent.com/u/78061?v=4)](https://github.com/simonbuehler "simonbuehler (3 commits)")[![vikas5914](https://avatars.githubusercontent.com/u/7912297?v=4)](https://github.com/vikas5914 "vikas5914 (2 commits)")[![erikn69](https://avatars.githubusercontent.com/u/4933954?v=4)](https://github.com/erikn69 "erikn69 (2 commits)")[![JuanDMeGon](https://avatars.githubusercontent.com/u/5510960?v=4)](https://github.com/JuanDMeGon "JuanDMeGon (2 commits)")[![Koozza](https://avatars.githubusercontent.com/u/1731647?v=4)](https://github.com/Koozza "Koozza (2 commits)")[![snellingio](https://avatars.githubusercontent.com/u/9887585?v=4)](https://github.com/snellingio "snellingio (2 commits)")[![mdprotacio](https://avatars.githubusercontent.com/u/482168?v=4)](https://github.com/mdprotacio "mdprotacio (1 commits)")[![mahansky](https://avatars.githubusercontent.com/u/1536298?v=4)](https://github.com/mahansky "mahansky (1 commits)")

---

Tags

laravelphpphp8traefikwebsocketsbeyondcodelaravel-websockets

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/blax-software-laravel-websockets/health.svg)

```
[![Health](https://phpackages.com/badges/blax-software-laravel-websockets/health.svg)](https://phpackages.com/packages/blax-software-laravel-websockets)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
