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)2189MITPHPPHP ^7.2|^8.0

Since Nov 25Pushed 1mo 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 1mo ago

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

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

[](#laravel-websockets)

Note

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

Plug-and-play WebSockets for Laravel with a Pusher-compatible protocol, a fast fork-based handler, and practical helpers for broadcasting and testing.

Why this package
----------------

[](#why-this-package)

- Drop-in broadcasting backend for Laravel apps that already use Echo/Pusher-compatible clients
- Fast local handler with async processing via `pcntl_fork`
- Protocol compatibility for both modern `websocket.*` and legacy `pusher:*` action formats
- Built-in developer ergonomics: helper functions, service methods, and rich test helpers

Install in 2 minutes
--------------------

[](#install-in-2-minutes)

1. Install package

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

2. Publish config

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

3. Start server

```
php artisan websockets:serve
```

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

Helper functions (broadcast from anywhere)
------------------------------------------

[](#helper-functions-broadcast-from-anywhere)

The package ships with global helpers in `src/helpers_global.php`.

```
// Broadcast to everyone on a channel
ws_broadcast('chat.message', ['text' => 'Hello'], 'chat');

// Whisper to specific socket IDs only
ws_whisper('chat.typing', ['typing' => true], ['1234.1', '1234.2'], 'chat');

// Broadcast to everyone except listed sockets
ws_broadcast_except('chat.message', ['text' => 'Server msg'], ['1234.1'], 'chat');

// Check if local unix-socket broadcaster is available
if (ws_available()) {
	ws_broadcast('app.health', ['ok' => true]);
}

// Build protocol auth payload for private/presence channels
$auth = wsSession('private-updates', ['user_id' => 7, 'user_info' => ['name' => 'Jane']]);
```

Service API
-----------

[](#service-api)

Use the service directly when you prefer explicit class calls over helpers.

```
use BlaxSoftware\LaravelWebSockets\Services\WebsocketService;

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

// Optional in-process tracking helpers
WebsocketService::setUserAuthed($socketId, $userId);
$authed = WebsocketService::getAuthedUsers();
```

Testing experience
------------------

[](#testing-experience)

The test suite includes helper-first patterns so WebSocket tests stay short and readable.

### Test helpers

[](#test-helpers)

- `newConnection()`
- `newActiveConnection(['channel'])`
- `newPrivateConnection('private-channel')`
- `newPresenceConnection('presence-channel', ['user_id' => 1, 'user_info' => [...]])`

### Example

[](#example)

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

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

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

Run tests:

```
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)

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md).

Security
--------

[](#security)

Please report vulnerabilities via 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).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance60

Regular maintenance activity

Popularity16

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity81

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

993d 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 (45 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

[kyrne/websocket

Integrated Pusher replacement.

121.6k1](/packages/kyrne-websocket)

PHPackages © 2026

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