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

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

zanderwar/php-websocket
=======================

A simple WebSocket Server and Client implementation in PHP.

v2.1.0(5y ago)09MITPHPPHP ^7.2

Since Apr 5Pushed 5y agoCompare

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

READMEChangelogDependenciesVersions (5)Used By (0)

 [![](https://camo.githubusercontent.com/c32f73a2d2e53972aa4187a1ffa7e720e107f2a72a7a1f1e4e4a8737eab4338e/68747470733a2f2f626c6f61746c6573732e6f72672f696d672f6c6f676f2e737667)](https://camo.githubusercontent.com/c32f73a2d2e53972aa4187a1ffa7e720e107f2a72a7a1f1e4e4a8737eab4338e/68747470733a2f2f626c6f61746c6573732e6f72672f696d672f6c6f676f2e737667)

Bloatless PHP WebSockets
========================

[](#bloatless-php-websockets)

 Simple WebSocket server and client implemented in PHP.

About
-----

[](#about)

This application is an extremely simple implementation of the [WebSocket Protocol](https://tools.ietf.org/html/rfc6455)in PHP. It includes a server as well as a client. This implementation is optimal to get started with WebSockets and learn something. As soon as you want to create a full featured websocket based application you might want to switch to more sophisticated solution.

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

[](#installation)

Clone or download the repository to your server. The package is also installable via composer running the following command:

`composer require bloatless/php-websocket`

### Requirements

[](#requirements)

- PHP &gt;= 7.2

Hint: You can use version 1.0 if you're still on PHP5.

Usage
-----

[](#usage)

- Adjust `cli/server.php` to your requirements.
- Run: `php cli/server.php`

This will start a websocket server. (By default on localhost:8000)

### Server example

[](#server-example)

This will create a websocket server listening on port 8000.

There a two applications registred to the server. The demo application will be available at `ws://localhost:8000/demo`and the status application will be available at `ws://localhost:8000/status`.

```
// Require neccessary files here...

$server = new \Bloatless\WebSocket\Server('127.0.0.1', 8000);

// Server settings:
$server->setMaxClients(100);
$server->setCheckOrigin(false);
$server->setAllowedOrigin('foo.lh');
$server->setMaxConnectionsPerIp(100);
$server->setMaxRequestsPerMinute(2000);

// Add your applications here:
$server->registerApplication('status', \Bloatless\WebSocket\Application\StatusApplication::getInstance());
$server->registerApplication('demo', \Bloatless\WebSocket\Application\DemoApplication::getInstance());

$server->run();
```

### Client example

[](#client-example)

This creates a WebSocket cliente, connects to a server and sends a message to the server:

```
$client = new \Bloatless\WebSocket\Client;
$client->connect('127.0.0.1', 8000, '/demo', 'foo.lh');
$client->sendData([
    'action' => 'echo',
    'data' => 'Hello Wolrd!'
]);
```

### Browser example

[](#browser-example)

The repository contains two demo-pages to call in your browser. You can find them in the `public` folder. The `index.html` is a simple application which you can use to send messages to the server.

The `status.html` will display various server information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.7% 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 ~224 days

Total

2

Last Release

2009d ago

### Community

Maintainers

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

---

Top Contributors

[![nekudo](https://avatars.githubusercontent.com/u/1132928?v=4)](https://github.com/nekudo "nekudo (67 commits)")[![nicokaiser](https://avatars.githubusercontent.com/u/238631?v=4)](https://github.com/nicokaiser "nicokaiser (6 commits)")[![dominics](https://avatars.githubusercontent.com/u/97427?v=4)](https://github.com/dominics "dominics (2 commits)")[![JoseRolles](https://avatars.githubusercontent.com/u/12932021?v=4)](https://github.com/JoseRolles "JoseRolles (1 commits)")[![mazhack](https://avatars.githubusercontent.com/u/392629?v=4)](https://github.com/mazhack "mazhack (1 commits)")[![olehs](https://avatars.githubusercontent.com/u/606709?v=4)](https://github.com/olehs "olehs (1 commits)")[![chrisharrison](https://avatars.githubusercontent.com/u/296186?v=4)](https://github.com/chrisharrison "chrisharrison (1 commits)")[![zanderwar](https://avatars.githubusercontent.com/u/13566916?v=4)](https://github.com/zanderwar "zanderwar (1 commits)")[![colindev](https://avatars.githubusercontent.com/u/1317798?v=4)](https://github.com/colindev "colindev (1 commits)")[![fushihara](https://avatars.githubusercontent.com/u/1039534?v=4)](https://github.com/fushihara "fushihara (1 commits)")

---

Tags

phpWebSocketswebsocket serverbloatless

### Embed Badge

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

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

###  Alternatives

[bloatless/php-websocket

A simple WebSocket Server and Client implementation in PHP.

59237.4k1](/packages/bloatless-php-websocket)[hannesvdvreken/guzzle-debugbar

A Guzzle middleware that logs requests to debugbar's timeline

76410.4k1](/packages/hannesvdvreken-guzzle-debugbar)[swoft/websocket-server

swoft websocket server component

16134.1k5](/packages/swoft-websocket-server)[hemiframe/php-websocket

PHP WebSocket server and client library

4911.0k](/packages/hemiframe-php-websocket)

PHPackages © 2026

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