PHPackages                             allansun/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. allansun/websocket

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

allansun/websocket
==================

WebSocket client and server

1.2.0(10y ago)24.5k1MITPHP

Since May 30Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (13)Used By (1)

Websocket Client for PHP
========================

[](#websocket-client-for-php)

[![Build Status](https://camo.githubusercontent.com/ea3b22ac47b8915298b9499ab2c556b8f4d507c6c863b1f5e8706b3424f5813d/68747470733a2f2f7472617669732d63692e6f72672f54657874616c6b2f776562736f636b65742d7068702e706e67)](https://travis-ci.org/Textalk/websocket-php)[![Coverage Status](https://camo.githubusercontent.com/4c6051897ac905bbe0777c612761443a68ffde1033860fe145083034ca15e7c4/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f54657874616c6b2f776562736f636b65742d7068702f62616467652e706e67)](https://coveralls.io/r/Textalk/websocket-php)

This package mainly contains a WebSocket client for PHP.

I made it because the state of other WebSocket clients I could found was either very poor (sometimes failing on large frames) or had huge dependencies (React…).

The Client should be good. If it isn't, tell me!

The Server there because much of the code would be identical in writing a server, and because it is used for the tests. To be really useful though, there should be a Connection-class returned from a new Connection, and the Server-class only handling the handshake. Then you could hold a full array of Connections and check them periodically for new data, send something to them all or fork off a process handling one connection. But, I have no use for that right now. (Actually, I would suggest a language with better asynchronous handling than PHP for that.)

Installing
----------

[](#installing)

Preferred way to install is with [Composer](https://getcomposer.org/).

Just add

```
"require": {
  "allansun/websocket": "1.*"
}

```

in your projects composer.json.

Client usage:
-------------

[](#client-usage)

```
require('vendor/autoload.php');

use WebSocket\Client;

$client = new Client("ws://echo.websocket.org/");
$client->send("Hello WebSocket.org!");

echo $client->receive(); // Will output 'Hello WebSocket.org!'
```

Developer install
-----------------

[](#developer-install)

Development depends on php, php-curl and php-xdebug.

```
# Will get composer, install dependencies and run tests
make test
```

License ([ISC](http://en.wikipedia.org/wiki/ISC_license))
---------------------------------------------------------

[](#license-isc)

Copyright (C) 2014, 2015 Textalk Copyright (C) 2015 Patrick McCarren - added payload fragmentation for huge payloads Copyright (C) 2015 Ignas Bernotas - added stream context options

Websocket PHP is free software: Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

See COPYING.

Changelog
---------

[](#changelog)

1.2.0

- Adding stream context options (to set e.g. SSL `allow_self_signed`).

1.1.2

- Fixed error message on broken frame.

1.1.1

- Adding license information.

1.1.0

- Supporting huge payloads.

1.0.3

- Bugfix: Correcting address in error-message

1.0.2

- Bugfix: Add port in request-header.

1.0.1

- Fixing a bug from empty payloads.

1.0.0

- Release as production ready.
- Adding option to set/override headers.
- Supporting basic authentication from user:pass in URL.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity70

Established project with proven stability

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

Recently: every ~45 days

Total

10

Last Release

3875d ago

Major Versions

0.1.1 → 1.0.02014-10-28

### Community

Maintainers

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

---

Top Contributors

[![fiddur](https://avatars.githubusercontent.com/u/148166?v=4)](https://github.com/fiddur "fiddur (11 commits)")[![pmccarren](https://avatars.githubusercontent.com/u/4959702?v=4)](https://github.com/pmccarren "pmccarren (11 commits)")[![allansun](https://avatars.githubusercontent.com/u/20531?v=4)](https://github.com/allansun "allansun (3 commits)")[![jaytaph](https://avatars.githubusercontent.com/u/241458?v=4)](https://github.com/jaytaph "jaytaph (1 commits)")[![krydos](https://avatars.githubusercontent.com/u/910691?v=4)](https://github.com/krydos "krydos (1 commits)")[![armen](https://avatars.githubusercontent.com/u/6529?v=4)](https://github.com/armen "armen (1 commits)")[![QuentinBellus](https://avatars.githubusercontent.com/u/7331499?v=4)](https://github.com/QuentinBellus "QuentinBellus (1 commits)")[![sloonz](https://avatars.githubusercontent.com/u/142145?v=4)](https://github.com/sloonz "sloonz (1 commits)")[![swmcdonnell](https://avatars.githubusercontent.com/u/6199058?v=4)](https://github.com/swmcdonnell "swmcdonnell (1 commits)")[![vkuptcov](https://avatars.githubusercontent.com/u/1507196?v=4)](https://github.com/vkuptcov "vkuptcov (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/allansun-websocket/health.svg)

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

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