PHPackages                             tansoft/websocketclient - 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. tansoft/websocketclient

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

tansoft/websocketclient
=======================

websocket client lib

1.0.1(7y ago)42692MITPHP

Since Jun 20Pushed 6y ago2 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

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

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

Simple websocket client and support data record and playback.

Depend on project [Textalk/websocket](https://github.com/Textalk/websocket-php/).

Installing
----------

[](#installing)

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

```
composer require tansoft/websocketclient

```

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

[](#client-usage)

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

class MyHandler implements WebSocket\ISocketHandler{
    public function onConnect(&$client){
        //init send something
        $client->send($reg);
    }
    public function onReceive(&$client, $msg){
        //receive something with $msg
        //return false for exit
        return true;
    }
    public function onError(&$client, $errno, $errmsg){
        echo('socket error '.$errno.':'.$errmsg);
        //return true for auto reconnect
        return true;
    }
}

$client = new WebSocket\WebSocketClient('ws://echo.websocket.org/', new MyHandler);
//setup auto ack settings
$client->setupAck('{"event":"ping"}', '{"event":"pong"}', KEEPALIVE_TIMEOUT_SECOND);

//setup rawdata record
$client->setupRawLog('rawdata.log');
$client->loop();

//or

//setup rawdata playback
//use flag WebSocket\WebSocketClient::RAWLOG_PLAYBACKMODE_QUICK for playback with no sleep
$client->setupRawLog('rawdata.log', WebSocket\WebSocketClient::RAWLOG_PLAYBACKMODE_NORMAL);
$client->loop();
```

Changelog
---------

[](#changelog)

1.0.0

- Support auto ack.
- Support event base callback.
- Support rawdata record and playback.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~23 days

Total

2

Last Release

2862d ago

### Community

Maintainers

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

---

Top Contributors

[![ryantology](https://avatars.githubusercontent.com/u/245054?v=4)](https://github.com/ryantology "ryantology (1 commits)")

---

Tags

websocketreplaytestcase

### Embed Badge

![Health badge](/badges/tansoft-websocketclient/health.svg)

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

###  Alternatives

[cboden/ratchet

PHP WebSocket library

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

Asynchronous WebSocket client

6148.9M214](/packages/ratchet-pawl)[ratchet/rfc6455

RFC6455 WebSocket protocol handler

23433.7M69](/packages/ratchet-rfc6455)[phrity/websocket

WebSocket client and server

2184.1M27](/packages/phrity-websocket)[amphp/websocket-client

Async WebSocket client for PHP based on Amp.

1613.0M39](/packages/amphp-websocket-client)[chrome-php/wrench

A simple PHP WebSocket implementation

673.7M4](/packages/chrome-php-wrench)

PHPackages © 2026

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