PHPackages                             warriorxk/phpwebsockets - 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. warriorxk/phpwebsockets

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

warriorxk/phpwebsockets
=======================

A websocket library with support for IPC using socket pairs

4.0.1(8mo ago)1225.3k↓50%5[1 PRs](https://github.com/WarriorXK/PHPWebSockets/pulls)MITPHPPHP ^7.4.0 || ^8.0.0CI passing

Since Dec 2Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/WarriorXK/PHPWebSockets)[ Packagist](https://packagist.org/packages/warriorxk/phpwebsockets)[ Docs](https://github.com/WarriorXK/PHPWebSockets)[ RSS](/packages/warriorxk-phpwebsockets/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (39)Used By (0)

PHPWebSockets
=============

[](#phpwebsockets)

[![Code documented](https://camo.githubusercontent.com/785e1b1e937617b109b1206d369736a6a6563c42005a0e20b075055087c75596/68747470733a2f2f636f6465646f63732e78797a2f57617272696f72584b2f504850576562536f636b6574732e737667)](https://codedocs.xyz/WarriorXK/PHPWebSockets/) Master: [![Build Status](https://camo.githubusercontent.com/c8e05b24a49d8243f7528d66015853164f2e2c052fede324e6d6298933329d58/68747470733a2f2f7472617669732d63692e636f6d2f57617272696f72584b2f504850576562536f636b6574732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/WarriorXK/PHPWebSockets) Develop: [![Build Status](https://camo.githubusercontent.com/98daa9bc48af8c75d24986f9f7fd0f6c38f0a160038d5c84473183a8e5a5614a/68747470733a2f2f7472617669732d63692e636f6d2f57617272696f72584b2f504850576562536f636b6574732e7376673f6272616e63683d646576656c6f70)](https://travis-ci.com/WarriorXK/PHPWebSockets)

A PHP library to accept and create websocket connections, we aim to be 100% compliant with the websocket RFC and use the [Autobahn test suite](http://autobahn.ws/testsuite/) to ensure so. Currently the server and the client are 100% compliant with the autobahn testsuite minus a few non-strict notices, the [compression extension](https://tools.ietf.org/html/rfc7692) for websockets will be implemented later

Server
------

[](#server)

For websocket servers a new \\PHPWebSockets\\Server instance should be created with a bind address and a port to listen on. For ease of use you can use the UpdatesWrapper class, this will trigger certain callables set on basic functions.

A basic websocket echo server would be:

```
require_once __DIR__ . '/vendor/autoload.php';

$wrapper = new \PHPWebSockets\UpdatesWrapper();
$wrapper->setMessageHandler(function(\PHPWebSockets\AConnection $connection, string $message, int $opcode) {

    echo 'Got message with length ' . strlen($message) . PHP_EOL;
    $connection->write($message, $opcode);

});

$server = new \PHPWebSockets\Server('tcp://0.0.0.0:9001');

while (TRUE) {
    $wrapper->update(0.1, $server->getConnections(TRUE));
}
```

If more control is required you can manually call `$server->update(0.1);` instead of using the wrapper, this will yield update objects which can be responded to.

Client
------

[](#client)

For connecting to a server the \\PHPWebSockets\\Client class should be constructed and the method connect($address, $port, $path) should be used to connect. For ease of use you can again use the UpdatesWrapper class or use `$server->update(0.1);` for better control.

A basic websocket echo client would be:

```
require_once __DIR__ . '/../vendor/autoload.php';

$wrapper = new \PHPWebSockets\UpdatesWrapper();
$wrapper->setMessageHandler(function(\PHPWebSockets\AConnection $connection, string $message, int $opcode) {

    echo 'Got message with length ' . strlen($message) . PHP_EOL;
    $connection->write($message, $opcode);

});

$client = new \PHPWebSockets\Client();
if (!$client->connect('tcp://localhost:9001/webSocket')) {
    die('Unable to connect to server: ' . $client->getLastError() . PHP_EOL);
}

while (TRUE) {
    $wrapper->update(0.1, [$client]);
}
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance70

Regular maintenance activity

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 98.1% of commits — single point of failure

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 ~103 days

Recently: every ~197 days

Total

32

Last Release

267d ago

Major Versions

1.8.1 → 2.0.02017-07-03

2.6.3 → 3.0.02020-10-22

3.1.5 → 4.0.02025-07-22

PHP version history (4 changes)1.3.0PHP &gt;=7.0.0

3.0.0PHP &gt;=7.3.0

3.0.1PHP ^7.3.0 || ^8.0.0

3.1.3PHP ^7.4.0 || ^8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b8b87973993ef47cc25725b8d7ea2a1569ab01e88d2fa2513d7a468df3430031?d=identicon)[WarriorXK](/maintainers/WarriorXK)

---

Top Contributors

[![WarriorXK](https://avatars.githubusercontent.com/u/640545?v=4)](https://github.com/WarriorXK "WarriorXK (309 commits)")[![lx-kevinmeijer](https://avatars.githubusercontent.com/u/213612943?v=4)](https://github.com/lx-kevinmeijer "lx-kevinmeijer (6 commits)")

---

Tags

daemonphpphp-daemonphp73php74websocketwebsocket-clientwebsocket-connectionwebsocket-connectionswebsocket-serverwebsocket-serverswebsocketsphpclientserverwebsocketSocketipcphpwebsockets

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/warriorxk-phpwebsockets/health.svg)

```
[![Health](https://phpackages.com/badges/warriorxk-phpwebsockets/health.svg)](https://phpackages.com/packages/warriorxk-phpwebsockets)
```

###  Alternatives

[swow/swow

Coroutine-based multi-platform support engine with a focus on concurrent I/O

1.3k2.1M84](/packages/swow-swow)[phrity/websocket

WebSocket client and server

2184.1M27](/packages/phrity-websocket)[datto/json-rpc-http

HTTP client and server for JSON-RPC 2.0

66525.9k5](/packages/datto-json-rpc-http)[hemiframe/php-websocket

PHP WebSocket server and client library

4911.0k](/packages/hemiframe-php-websocket)[iris/nsq_to_swoole

a strong php client for NSQ using swoole extension

354.8k](/packages/iris-nsq-to-swoole)

PHPackages © 2026

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