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

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

alexboo/websocket-handler
=========================

websocket handler

0.2.x-dev(10y ago)0210GPLv2PHPPHP &gt;=5.4.0

Since Dec 2Pushed 8y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (5)Used By (0)

WebSocketHandler
================

[](#websockethandler)

A small library to define a handler for web socket command

Install
-------

[](#install)

You can install it library with composer

```
composer require alexboo/websocket-handler

```

Using
-----

[](#using)

Yoy need create Handler factory for create handler for the processing of each command. It must implements HandlerFactoryInterface. In Handler factory you can add ACL before create handler.

### Example handler factory

[](#example-handler-factory)

```

class HandlerFactory implements HandlerFactoryInterface
{
    /**
     * Get handler for command
     * @param Client $client
     * @param $command
     * @return Handler
     */
    public function getHandler(Client $client, $command)
    {
        $handler = new Handler();
        switch ($command) {
            case "auth":
                $handler->setObject(new AuthService(), "auth");
                break;
            case "message":
                $handler->setClosure(function(){
                    // do something
                });
                break;
        }

        return $handler;
    }

    /**
     * Client open connection
     * @param Client $client
     * @return mixed
     */
    public function open(Client $client){

    }

    /**
     * Client close connection
     * @param Client $client
     * @return mixed
     */
    public function close(Client $client)
    {
    }
}

```

Then you can start web socket server

```
$wsHandler =  WebSocketHandler::getInstance(new HandlerFactory());

$ioServer = IoServer::factory(
    new HttpServer(new \Ratchet\WebSocket\WsServer($wsHandler)),
    8001
);

$ioServer->run();

```

Parameters that must be passed to the handler defined on the basis ReflectionApi. You can request information about the client specifying the parameters of the "Client" class or query parameters in object implements Alexboo\\WebSocketHandler\\Interfaces\\RequestInterface.

Example
-------

[](#example)

```
class AuthRequest implements RequestInterface {
   public function setData($data){

   }
}

class AuthService {

   public function auth(Client $client, AuthRequest $request)
   {

   }
}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Total

4

Last Release

3772d ago

### Community

Maintainers

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

---

Top Contributors

[![alexboo](https://avatars.githubusercontent.com/u/2115000?v=4)](https://github.com/alexboo "alexboo (16 commits)")

---

Tags

websockethandler

### Embed Badge

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

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

###  Alternatives

[gos/web-socket-bundle

Symfony Web Socket Bundle

6202.2M8](/packages/gos-web-socket-bundle)[consik/yii2-websocket

Yii2 websocket server component

9275.9k2](/packages/consik-yii2-websocket)[eole/sandstone

Silex RestApi with Websockets.

1115.2k1](/packages/eole-sandstone)[takielias/codeigniter-websocket

CodeIgniter Websocket using Ratchet Websocket technology. Inspired by https://github.com/romainrg/ratchet\_client

609.1k](/packages/takielias-codeigniter-websocket)[takielias/codeigniter4-websocket

Websocket using Ratchet Websocket technology for CodeIgniter 4

883.0k](/packages/takielias-codeigniter4-websocket)[joni-jones/yii2-wschat

Online chat based on web sockets and ratchet php

981.3k](/packages/joni-jones-yii2-wschat)

PHPackages © 2026

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