PHPackages                             nailfor/php-websocket-client - 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. nailfor/php-websocket-client

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

nailfor/php-websocket-client
============================

a websocket client library for php

0.1.1(7y ago)021LGPLPHP

Since Apr 3Pushed 7y ago1 watchersCompare

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

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

PHP WebSocket Client
====================

[](#php-websocket-client)

phpWebSocketClient is an WebSocket client library for PHP. Its based on the reactPHP socket-client and added the WebSocket protocol specific functions.

Goal
----

[](#goal)

Goal of this project is easy to use WebSocket client for PHP in a modern architecture without using any php modules.

- Protocol specifications: [https://developer.mozilla.org/en-US/docs/Web/API/WebSockets\_API/Writing\_WebSocket\_servers](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers)

Example
-------

[](#example)

```

use nailfor\websocket\ClientFactory;

class WebSocketTest
{
    public function receiveMsg($reason)
    {
        echo "RECEIVE:";
        print_r($reason->getMessage());
    }

    public function afterConnect($reason)
    {
        $data = [
            "somedata" => "peesdata",
        ];
        //'topic' is a TOPIC_NAME from options
        ClientFactory::$client->publish('topic', $data);
    }

    public function errorMsg($reason)
    {
        echo $reason->getMessage(). PHP_EOL;
        exit;
    }

    public function closeMsg()
    {
        echo "closed!!!!". PHP_EOL;
        exit;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $options = [
            'topics' => [
                //TOPIC_NAME => events[]
                'topic' => [
                    'events' => [
                        //EVENT_NAME=>function
                        'PUBLISH_RECEIVED'  => [$this, 'receiveMsg'],
                    ],
                ],
            ],
            'connect'   => [$this, 'afterConnect'],
            'timeout'   => [$this, 'errorMsg'],
            'error'     => [$this, 'errorMsg'],
            'close'     => [$this, 'closeMsg'],
        ];

        ClientFactory::run('ws://127.0.0.1:8080', $options);
    }
}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Total

2

Last Release

2591d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f0e23d07efd81dccb69223c1ef1897b2aa0d3eb74d7b2ee3627160406d43334?d=identicon)[nailfor](/maintainers/nailfor)

---

Top Contributors

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

---

Tags

websocketiot

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nailfor-php-websocket-client/health.svg)

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

###  Alternatives

[cboden/ratchet

PHP WebSocket library

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

Asynchronous WebSocket client

6148.9M215](/packages/ratchet-pawl)[gos/web-socket-bundle

Symfony Web Socket Bundle

6202.2M8](/packages/gos-web-socket-bundle)[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)[gabrielbull/websocket-client

A simple PHP WebSocket Client

8297.2k](/packages/gabrielbull-websocket-client)[plesk/ratchetphp

PHP WebSocket library

1865.9k2](/packages/plesk-ratchetphp)

PHPackages © 2026

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