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

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

narenknn/websocket
==================

WebSocket client and server

02PHP

Since Mar 3Pushed 2mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Websocket Client and Server for PHP
===================================

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

[![Build Status](https://github.com/Textalk/websocket-php/actions/workflows/acceptance.yml/badge.svg)](https://github.com/Textalk/websocket-php/actions)[![Coverage Status](https://camo.githubusercontent.com/0cd2e339550291ccb3118c83248ab6ad2643ae7ce0bd8ce43d21a2d570271296/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f54657874616c6b2f776562736f636b65742d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Textalk/websocket-php)

Description
-----------

[](#description)

This project was forked from archived project [Textalk/websocket-php](https://github.com/Textalk/websocket-php) and upgraded with non-blocking reads. Primary goal is to use only the client for non-blocking reads (server is largely left unchanged, but the state is not checked anymore). Non-blocking reads is enabled for client by default and returns empty message immediately. This feature is useful, if one has a threading mechanism already and just want to check for received messages.

Websocket Client and Server for PHP
-----------------------------------

[](#websocket-client-and-server-for-php-1)

This library contains WebSocket client and server for PHP.

The client and server provides methods for reading and writing to WebSocket streams. It does not include convenience operations such as listeners and implicit error handling.

Documentation
-------------

[](#documentation)

- [Client](docs/Client.md)
- [Server](docs/Server.md)
- [Examples](docs/Examples.md)
- [Changelog](docs/Changelog.md)
- [Contributing](docs/Contributing.md)

Installing
----------

[](#installing)

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

```
composer require textalk/websocket

```

- Current version support PHP versions `^7.4|^8.0`.
- For PHP `7.2` and `7.3` support use version [`1.5`](https://github.com/Textalk/websocket-php/tree/1.5.0).
- For PHP `7.1` support use version [`1.4`](https://github.com/Textalk/websocket-php/tree/1.4.0).
- For PHP `^5.4` and `7.0` support use version [`1.3`](https://github.com/Textalk/websocket-php/tree/1.3.0).

Client
------

[](#client)

The [client](docs/Client.md) can read and write on a WebSocket stream. It internally supports Upgrade handshake and implicit close and ping/pong operations.

```
$client = new WebSocket\Client("ws://echo.websocket.org/");
$client->text("Hello WebSocket.org!");
echo $client->receive();
$client->close();
```

Server
------

[](#server)

The library contains a rudimentary single stream/single thread [server](docs/Server.md). It internally supports Upgrade handshake and implicit close and ping/pong operations.

Note that it does **not** support threading or automatic association ot continuous client requests. If you require this kind of server behavior, you need to build it on top of provided server implementation.

```
$server = new WebSocket\Server();
$server->accept();
$message = $server->receive();
$server->text($message);
$server->close();
```

### License and Contributors

[](#license-and-contributors)

[ISC License](COPYING.md)

Fredrik Liljegren, Armen Baghumian Sankbarani, Ruslan Bekenev, Joshua Thijssen, Simon Lipp, Quentin Bellus, Patrick McCarren, swmcdonnell, Ignas Bernotas, Mark Herhold, Andreas Palm, Sören Jensen, pmaasz, Alexey Stavrov, Michael Slezak, Pierre Seznec, rmeisler, Nickolay V. Shmyrev, Christoph Kempen, Marc Roberts, Antonio Mora, Simon Podlipsky, etrinh.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance57

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

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

---

Top Contributors

[![sirn-se](https://avatars.githubusercontent.com/u/4255391?v=4)](https://github.com/sirn-se "sirn-se (178 commits)")[![narenknn](https://avatars.githubusercontent.com/u/29030642?v=4)](https://github.com/narenknn "narenknn (15 commits)")[![pmccarren](https://avatars.githubusercontent.com/u/4959702?v=4)](https://github.com/pmccarren "pmccarren (14 commits)")[![fiddur](https://avatars.githubusercontent.com/u/148166?v=4)](https://github.com/fiddur "fiddur (11 commits)")[![slezakattack](https://avatars.githubusercontent.com/u/1261638?v=4)](https://github.com/slezakattack "slezakattack (3 commits)")[![larsgust](https://avatars.githubusercontent.com/u/97449892?v=4)](https://github.com/larsgust "larsgust (3 commits)")[![zapling](https://avatars.githubusercontent.com/u/15123086?v=4)](https://github.com/zapling "zapling (2 commits)")[![Logioniz](https://avatars.githubusercontent.com/u/1052312?v=4)](https://github.com/Logioniz "Logioniz (2 commits)")[![marcroberts](https://avatars.githubusercontent.com/u/43874?v=4)](https://github.com/marcroberts "marcroberts (2 commits)")[![rmeisler-applovin](https://avatars.githubusercontent.com/u/99207377?v=4)](https://github.com/rmeisler-applovin "rmeisler-applovin (2 commits)")[![matias-pool](https://avatars.githubusercontent.com/u/40055649?v=4)](https://github.com/matias-pool "matias-pool (1 commits)")[![manuelm](https://avatars.githubusercontent.com/u/357694?v=4)](https://github.com/manuelm "manuelm (1 commits)")[![nshmyrev](https://avatars.githubusercontent.com/u/2886672?v=4)](https://github.com/nshmyrev "nshmyrev (1 commits)")[![peterjah](https://avatars.githubusercontent.com/u/34547263?v=4)](https://github.com/peterjah "peterjah (1 commits)")[![krydos](https://avatars.githubusercontent.com/u/910691?v=4)](https://github.com/krydos "krydos (1 commits)")[![QuentinBellus](https://avatars.githubusercontent.com/u/7331499?v=4)](https://github.com/QuentinBellus "QuentinBellus (1 commits)")[![RaoH](https://avatars.githubusercontent.com/u/738935?v=4)](https://github.com/RaoH "RaoH (1 commits)")[![rmeisler](https://avatars.githubusercontent.com/u/1885391?v=4)](https://github.com/rmeisler "rmeisler (1 commits)")[![amorAaluxion](https://avatars.githubusercontent.com/u/68215455?v=4)](https://github.com/amorAaluxion "amorAaluxion (1 commits)")[![RobQuistNL](https://avatars.githubusercontent.com/u/1442796?v=4)](https://github.com/RobQuistNL "RobQuistNL (1 commits)")

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

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

2.8k73.3M318](/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)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

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

78126.4M414](/packages/react-http)

PHPackages © 2026

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