PHPackages                             wrench/wrench - 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. wrench/wrench

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

wrench/wrench
=============

PHP WebSocket client/server library

v2.0.11(5y ago)5903.1M—3.5%209[16 issues](https://github.com/varspool/Wrench/issues)[1 PRs](https://github.com/varspool/Wrench/pulls)10WTFPLPHPPHP &gt;=5.3CI failing

Since Dec 28Pushed 4y ago34 watchersCompare

[ Source](https://github.com/varspool/Wrench)[ Packagist](https://packagist.org/packages/wrench/wrench)[ Docs](http://github.com/varspool/Wrench)[ RSS](/packages/wrench-wrench/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (23)Used By (10)

Wrench
======

[](#wrench)

Simple WebSocket Client/Server for PHP
--------------------------------------

[](#simple-websocket-clientserver-for-php)

- [![Latest Stable Version](https://camo.githubusercontent.com/57ee37ec6f6c548a44d1f65023d11d3bac36ea7008e43609a592ea97b1d45b9c/68747470733a2f2f706f7365722e707567782e6f72672f7772656e63682f7772656e63682f762f737461626c65)](https://packagist.org/packages/wrench/wrench)
- [![Latest Unstable Version](https://camo.githubusercontent.com/4b38c9963450c79df2b3775f807f9d7be1a9fcf31f68b9c8b51eb555e71c8388/68747470733a2f2f706f7365722e707567782e6f72672f7772656e63682f7772656e63682f762f756e737461626c65)](https://packagist.org/packages/wrench/wrench)
- [![Build Status](https://camo.githubusercontent.com/f349d6b1e3a3bf65934c0b24a0fdae54e9564bb615d595911792491082e75b73/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f76617273706f6f6c2f5772656e63682e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/varspool/Wrench)
- Documentation: [wrench.readthedocs.org](http://wrench.readthedocs.org/en/latest/index.html)

A simple websocket server and client package for PHP 7.1.

Installation
------------

[](#installation)

The library is PSR-4 compatible, with a vendor name of **Wrench**. It's available on Composer as `wrench/wrench`, so you can:

```
composer require wrench/wrench ~3.0
```

Usage
-----

[](#usage)

This creates a server on 127.0.0.1:8000 with one Application that listens for WebSocket requests to `ws://localhost:8000/echo` and `ws://localhost:8000/chat`:

### Server

[](#server)

```
/**
 * An example application, that just echoes the received data back to the connection that sent it
 */
$app = new class implements \Wrench\Application\DataHandlerInterface
{
    public function onData(string $data, \Wrench\Connection $connection): void
    {
        $connection->send($data);
    }
};

// A websocket server, listening on port 8000
$server = new \Wrench\BasicServer('ws://localhost:8000', array(
    'allowed_origins' => array(
        'mysite.com',
        'mysite.dev.localdomain'
    )
));

$server->registerApplication('echo', $app);
$server->registerApplication('chat', new \My\ChatApplication());
$server->setLogger($monolog); // PSR3
$server->run();
```

### Client

[](#client)

```
/**
 * A client side example, that sends a string and will receive the data back to the connection that sent it
 */
$client = new Client('ws://localhost:8000, http://localhost:8000);
$client->connect();
$client->sendData('hello');
$response = $client->receive()[0]->getPayload();
$client->disconnect();
```

Releases and Changelog
----------------------

[](#releases-and-changelog)

See the [CHANGELOG](CHANGELOG.md) for detailed information about changes between releases.

### PHP5 Support

[](#php5-support)

The latest major release dropped support for PHP versions prior to 7.1. If you need support for older versions of PHP, see the 2.0 branch. The latest 2.0 branch release is 2.0.8. You can install it with:

```
composer require wrench/wrench ~2.0

```

Developing
----------

[](#developing)

- Run `./vendor/bin/phpcs` and fix any errors that you come across
- Run `./vendor/bin/phpunit --exclude-group large,medium` for a fast test between changes

See Also
--------

[](#see-also)

- [Ratchet](https://github.com/cboden/Ratchet) an excellent Websocket layer for React.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity65

Solid adoption and visibility

Community44

Growing community involvement

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 75.6% 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 ~143 days

Recently: every ~0 days

Total

20

Last Release

2169d ago

Major Versions

v2.0.9-rc1 → v3.0.0-rc12020-02-21

PHP version history (2 changes)v2.0.0PHP &gt;=5.3

v3.0.0-rc1PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a1fd1e7045090ca677014a06fee68bb9cfd75d4286bb8d9da181b7d1d0db032?d=identicon)[phiamo](/maintainers/phiamo)

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

![](https://www.gravatar.com/avatar/8cf35a6fd0208fd0f301e44994d8c9056c3177b35f77bce1a816e19de0c7972b?d=identicon)[nexen2](/maintainers/nexen2)

---

Top Contributors

[![dominics](https://avatars.githubusercontent.com/u/97427?v=4)](https://github.com/dominics "dominics (263 commits)")[![nekudo](https://avatars.githubusercontent.com/u/1132928?v=4)](https://github.com/nekudo "nekudo (38 commits)")[![Alarmfifa](https://avatars.githubusercontent.com/u/3095492?v=4)](https://github.com/Alarmfifa "Alarmfifa (7 commits)")[![nexen2](https://avatars.githubusercontent.com/u/11517874?v=4)](https://github.com/nexen2 "nexen2 (7 commits)")[![nicokaiser](https://avatars.githubusercontent.com/u/238631?v=4)](https://github.com/nicokaiser "nicokaiser (6 commits)")[![DaSpors](https://avatars.githubusercontent.com/u/623201?v=4)](https://github.com/DaSpors "DaSpors (3 commits)")[![joy2fun](https://avatars.githubusercontent.com/u/7264066?v=4)](https://github.com/joy2fun "joy2fun (2 commits)")[![dobrakmato](https://avatars.githubusercontent.com/u/779469?v=4)](https://github.com/dobrakmato "dobrakmato (2 commits)")[![feifengxlq](https://avatars.githubusercontent.com/u/1271021?v=4)](https://github.com/feifengxlq "feifengxlq (2 commits)")[![guweigang](https://avatars.githubusercontent.com/u/178500?v=4)](https://github.com/guweigang "guweigang (2 commits)")[![Rupert-RR](https://avatars.githubusercontent.com/u/1748972?v=4)](https://github.com/Rupert-RR "Rupert-RR (2 commits)")[![jfcherng](https://avatars.githubusercontent.com/u/6594915?v=4)](https://github.com/jfcherng "jfcherng (1 commits)")[![huanga](https://avatars.githubusercontent.com/u/732970?v=4)](https://github.com/huanga "huanga (1 commits)")[![mattexx](https://avatars.githubusercontent.com/u/112029?v=4)](https://github.com/mattexx "mattexx (1 commits)")[![mazhack](https://avatars.githubusercontent.com/u/392629?v=4)](https://github.com/mazhack "mazhack (1 commits)")[![mfairchild365](https://avatars.githubusercontent.com/u/498678?v=4)](https://github.com/mfairchild365 "mfairchild365 (1 commits)")[![mgiustiniani](https://avatars.githubusercontent.com/u/1478947?v=4)](https://github.com/mgiustiniani "mgiustiniani (1 commits)")[![evolve32](https://avatars.githubusercontent.com/u/155657413?v=4)](https://github.com/evolve32 "evolve32 (1 commits)")[![emadruida](https://avatars.githubusercontent.com/u/547183?v=4)](https://github.com/emadruida "emadruida (1 commits)")[![bboer](https://avatars.githubusercontent.com/u/2079578?v=4)](https://github.com/bboer "bboer (1 commits)")

---

Tags

phpwebsocketswrenchwebsocketWebSocketshybi

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[cboden/ratchet

PHP WebSocket library

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

RFC6455 WebSocket protocol handler

23433.7M69](/packages/ratchet-rfc6455)[chrome-php/wrench

A simple PHP WebSocket implementation

673.7M4](/packages/chrome-php-wrench)[rx/websocket

Websockets for PHP using Rx

34181.5k2](/packages/rx-websocket)[hemiframe/php-websocket

PHP WebSocket server and client library

4911.0k](/packages/hemiframe-php-websocket)[plesk/ratchetphp

PHP WebSocket library

1865.9k2](/packages/plesk-ratchetphp)

PHPackages © 2026

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