PHPackages                             noflash/tinyws - 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. noflash/tinyws

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

noflash/tinyws
==============

High performance, flexible, RFC-complaint &amp; well documented WebSockets server library.

3331PHP

Since Feb 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/kiler129/TinyWs)[ Packagist](https://packagist.org/packages/noflash/tinyws)[ RSS](/packages/noflash-tinyws/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PROJECT ARCHIVED
================

[](#project-archived)

Sadly I don't have time to maintain this project (along with CherryHTTP). To this day I didn't find fast alternatives yet. However, I can no longer pretend that this old code is something which should be use in production ;)

---

TinyWs
======

[](#tinyws)

High performance, flexible, RFC-complaint &amp; well documented WebSockets server library. It's licensed under MIT, so it can be used in any project (even commercial one) free of charge. Despite repository short living time code is production-ready. In fact it's actively used everyday by many people, so I decided to make it open-source to make Internet a better place.

There are many PHP WebSocket libraries out there. Unfortunately most of them are cra^Cnot as good as they looks. Few of them are pretty decent, but their license doesn't allow flexible commercial-grade usage. Everyone who knows me know can confirm I'm performance freak, which also reflects in that project. TinyWs isn't perfect, it have some limitations. However none of them are really limiting it's usage.

### What is supported and what's not?

[](#what-is-supported-and-whats-not)

WebSocket protocol was a insecure and buggy mess for long, long time. As of [RFC 6455](https://tools.ietf.org/html/rfc6455) situation changed - it can be considered as rather good protocol. Library is almost 100% RFC-complaint (see [tests](https://github.com/kiler129/TinyWs/tree/master/tests).) and supports 13th protocol version only. It's not worth supporting older ones (they are deprecated anyway).

However due to lack of time few features aren't implemented:

- **SSL**: work in progress
- **Deep configuration**: some parameters cannot be configured (eg. max payload)
- **IPv6**: it should work, but it cannot be considered as tested
- **Origin**: currently server ignores origin and accepts any
- **Automatic fragmentation**: not an limitation, but missing improvement (but it isn't easy to implement **properly**)
- **Protocol extensions**: there are actually no practical usage for them now (except per-packet compression)
- **Packets compression**: considered more like Chrome-experiment with more cons than pros
- **WebSocket over SPDY**: it's only an experiment for now
    You could treat list above as small roadmap rather than list arguments against using this library ;)

Usage
-----

[](#usage)

### Requirements

[](#requirements)

- PHP &gt;=5.3 (5.6+ is recommended due to performance improvements)
- PHP modules: OpenSSL, mbstring
- [CherryHttp](https://github.com/kiler129/CherryHttp)
- [PSR-3 interfaces](https://github.com/php-fig/log)
- [PSR-3 complaint logger](https://packagist.org/search/?tags=psr-3) is recommended (eg. lightweight [Shout](https://github.com/kiler129/Shout))

### Installation

[](#installation)

#### Using composer

[](#using-composer)

Composer is preferred method of installation due to it's simplicity and automatic dependencies management.

1. You need composer of course - [installation takes less than a minute](https://getcomposer.org/download/)
2. Run `php composer.phar require noflash/tinyws:dev-master` in your favourite terminal to install TinyWs with dependencies
3. Include `vendor/autoload.php` in your application source code
4. If you want to see logs from server you need to install [PSR-3 complaint logger](https://packagist.org/search/?tags=psr-3), eg. `php composer.phar require noflash/shout`

#### Manual

[](#manual)

Details will be available soon.
*Basically you need to download [CherryHttp](https://github.com/kiler129/CherryHttp), [PSR-3 interfaces](https://github.com/php-fig/log) and [PSR-3 complaint logger](https://packagist.org/search/?tags=psr-3). Next put them in directory (eg. vendor) and include all files (or use PSR-4 complaint autoloader). Some details can be found in [examples README](https://github.com/kiler129/TinyWs/blob/master/examples/README.md)*

### Basic usage

[](#basic-usage)

Everytime message arrives, client connect/disconnect or some sort of exception occur TinyWs calls your own "ClientsHandler". It's just an object implementing (well documented) [`ClientsHandlerInterface`](https://github.com/kiler129/TinyWs/blob/master/src/ClientsHandlerInterface.php) interface. To simplify usage in really basic applications you can also just extend [`AbstractClientsHandler`](https://github.com/kiler129/TinyWs/blob/master/src/AbstractClientsHandler.php) and implement onMessage() method only.
How simple is that? Take a look at [echo server implementation](https://github.com/kiler129/TinyWs/blob/master/examples/echoServer.php).

FAQ
---

[](#faq)

#### Is it stable?

[](#is-it-stable)

Long time before library was published on GitHub it was tested under various conditions. It was verified to work flawless in commercial application with multiple users using different software configurations.

#### Is it fast enough to *PLACE SCENARIO HERE*?

[](#is-it-fast-enough-to-place-scenario-here)

Every piece of that code is written with performance in mind. There's no faster PHP-bases WebSocket server on the market ;)

Notes:

- Disable X-Debug in production environment (it really matters). You need to comment out module in php.ini (setting xdebug.\* to 0 is not enough).
- Use \*nix operating system - handling large amount of connections on Windows is not so efficient.

#### Could you add *PLACE FEATURE NAME HERE*?

[](#could-you-add-place-feature-name-here)

Every feature request will be considered. Library is under active development, however I cannot implement everything right away myself, so pull-requests are kindly welcomed.

#### Does it work in HHVM environment?

[](#does-it-work-in-hhvm-environment)

Unfortunately I don't have professional expedience with this platform and cannot make any guaranties.

#### Why configuration is done using constants? It's against OOP!

[](#why-configuration-is-done-using-constants-its-against-oop)

I spent many hours rethinking &amp; refactoring that part of library and it ended that way for many reasons.
First of all you need to know multiuser network service differ from standard PHP a lot. Since it uses I/O multiplexing to handle multiple connections using single thread (more in *Internal notes* section) only one instance of Server can be running at the same time.
Since there's no practical usage of multiple Server instances it's also not worth to support per instance configuration (which degrades performance significantly).

Internal notes (for hackers)
----------------------------

[](#internal-notes-for-hackers)

#### How it works?

[](#how-it-works)

Before you start thinking about understanding internals of this library you have to understand protocol construction. It's best to read whole [RFC 6455](https://tools.ietf.org/html/rfc6455). Simple chart for overall application flow is planned to land here. In meantime you can check code itself - it's well documented using industry standard [phpDocumentor](http://manual.phpdoc.org).

#### Multiple connections handling mechanism

[](#multiple-connections-handling-mechanism)

#### Why some methods uses type-hinting and some not?

[](#why-some-methods-uses-type-hinting-and-some-not)

These questions are covered by [CherryHttp README](https://github.com/kiler129/CherryHttp/blob/master/README.md).

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 96.4% 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/fa7072dc8b9e794c8e0be058496938c990e9b515f8b5c7c6193b79ca077e50b1?d=identicon)[kiler129](/maintainers/kiler129)

---

Top Contributors

[![kiler129](https://avatars.githubusercontent.com/u/1227834?v=4)](https://github.com/kiler129 "kiler129 (27 commits)")[![luklewluk](https://avatars.githubusercontent.com/u/6748300?v=4)](https://github.com/luklewluk "luklewluk (1 commits)")

### Embed Badge

![Health badge](/badges/noflash-tinyws/health.svg)

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

###  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)
