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

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

ekstazi/websocket-common
========================

Base amphp based stream interfaces for client and server websocket implementations

2.1.1(6y ago)0322MITPHPPHP &gt;=7.2

Since Apr 9Pushed 6y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (4)Versions (5)Used By (2)

websocket-common
================

[](#websocket-common)

Base stream interfaces for client and server websocket implementations

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

[](#installation)

This package can be installed as a Composer dependency.

`composer require ekstazi/websocket-common`

Requirements
============

[](#requirements)

PHP 7.2+

Interfaces
==========

[](#interfaces)

Three interfaces provided

`interface Reader extends InputStream`
--------------------------------------

[](#interface-reader-extends-inputstream)

### Methods

[](#methods)

#### `read(): Promise`

[](#read-promisestring)

Reads data from the stream. Return `Promise` that resolves with a string when new data is available or `null` if the stream has closed.

`interface Writer extends OutputStream`
---------------------------------------

[](#interface-writer-extends-outputstream)

### Constants

[](#constants)

#### `const MODE_BINARY = "binary"`

[](#const-mode_binary--binary)

Send data as binary frames. This mode used by default.

#### `const MODE_TEXT = 'text'`

[](#const-mode_text--text)

Send data as utf-8 text frames.

### Methods

[](#methods-1)

#### `public function setDefaultMode(string $mode): void`

[](#public-function-setdefaultmodestring-mode-void)

Set default mode to write frames.

#### `public function getDefaultMode(): string`

[](#public-function-getdefaultmode-string)

Get current default write mode.

#### `public function write(string $data, string $mode = null): Promise`

[](#public-function-writestring-data-string-mode--null-promiseint)

Write data with specified write mode. By default value `Writer::getMode()` used. Return promise that resolves with number of bytes written

#### `public function end(string $finalData = "", string $mode = null): Promise`

[](#public-function-endstring-finaldata---string-mode--null-promise)

Marks the stream as no longer writable. Optionally writes a final data chunk before. Note that this is not the same as forcefully closing the stream. This method waits for all pending writes to complete before closing the stream. Socket streams implementing this interface should only close the writable side of the stream.

`interface Connection extends Reader, Writer`
---------------------------------------------

[](#interface-connection-extends-reader-writer)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

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

Total

4

Last Release

2220d ago

Major Versions

1.0 → 2.02020-04-09

### Community

Maintainers

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

---

Top Contributors

[![Ekstazi](https://avatars.githubusercontent.com/u/992738?v=4)](https://github.com/Ekstazi "Ekstazi (6 commits)")

---

Tags

httpstreamasyncnon-blockingwebsocketampamphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k4.5M81](/packages/amphp-http-server)[amphp/websocket-client

Async WebSocket client for PHP based on Amp.

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

Shared code for websocket servers and clients.

453.1M9](/packages/amphp-websocket)[amphp/byte-stream

A stream abstraction to make working with non-blocking I/O simple.

392116.2M104](/packages/amphp-byte-stream)[amphp/http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.

7286.8M137](/packages/amphp-http-client)[hhxsv5/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.

3.9k676.0k10](/packages/hhxsv5-laravel-s)

PHPackages © 2026

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