PHPackages                             6phere/php-websocket - 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. 6phere/php-websocket

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

6phere/php-websocket
====================

Asynchronous WebSocket client

v1.1.5(6y ago)01111MITPHP

Since Jul 31Pushed 5y agoCompare

[ Source](https://github.com/6phere/php-websocket)[ Packagist](https://packagist.org/packages/6phere/php-websocket)[ RSS](/packages/6phere-php-websocket/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

PHP WebSocket
=============

[](#php-websocket)

Asynchronous WebSocket client client library for PHP. Supports HyBi, as well as Hixie #76 (no point).

This was built purely to be a client, as the majority of the WS clients available also contain servers and are very bloated.

Installation
============

[](#installation)

Using composer:

```
composer require sixphere\php-websocket

```

Usage
=====

[](#usage)

Since this really lends itself to being an asynchronous app, it is built to use the React event loops and resolver since there's a good chance they'll be in your project already and this lets you attach to the same loop.

```
$loop = \React\EventLoop\Factory::create();
$dns_factory = new React\Dns\Resolver\Factory();
$resolver = $dns_factory->createCached('8.8.8.8', $loop);

$client = new \Sixphere\WebSocket\Client('ws://127.0.0.1:1337/chat', $loop, $resolver);

//Most WS servers will complain/forbid if there is no origin header
$client->setOrigin('127.0.0.1');

$client->connect();

$client->on('stateChange', function($newState){
    echo "State changed to: $newState\n";
});

$client->on('message', function($message) use ($client){
    echo "New message: \n";
    echo $message;

    $client->send('This is a response message');
});

$loop->run();
```

Other available events are `connecting`, `connect`, `disconnecting`, `disconnect`

HTTP basic auth is also supported via the URI inf the form `user:pass@host`

Any feedback is most welcome

This is a fork from:

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71% 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

Unknown

Total

1

Last Release

2483d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/989068cdcc5cc8249ba649c566903058d9f7f1a61caa24e662b0984e40ffdda1?d=identicon)[pablo.roman](/maintainers/pablo.roman)

![](https://www.gravatar.com/avatar/7610df99e02a00b49296911caccfd5a6f862ccec254921169505e8c6ac91eaf4?d=identicon)[jesusmariajurado](/maintainers/jesusmariajurado)

---

Top Contributors

[![calcinai](https://avatars.githubusercontent.com/u/2415868?v=4)](https://github.com/calcinai "calcinai (22 commits)")[![romanalfaro](https://avatars.githubusercontent.com/u/4057210?v=4)](https://github.com/romanalfaro "romanalfaro (6 commits)")[![mattrenner](https://avatars.githubusercontent.com/u/1264226?v=4)](https://github.com/mattrenner "mattrenner (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/6phere-php-websocket/health.svg)

```
[![Health](https://phpackages.com/badges/6phere-php-websocket/health.svg)](https://phpackages.com/packages/6phere-php-websocket)
```

###  Alternatives

[cboden/ratchet

PHP WebSocket library

6.4k21.4M239](/packages/cboden-ratchet)[ratchet/pawl

Asynchronous WebSocket client

6148.9M214](/packages/ratchet-pawl)[jaggedsoft/php-binance-api

PHP Binance API is an asynchronous PHP library for the Binance API designed to be easy to use.

644179.0k4](/packages/jaggedsoft-php-binance-api)[plesk/ratchetphp

PHP WebSocket library

1865.9k2](/packages/plesk-ratchetphp)

PHPackages © 2026

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