PHPackages                             provm/events - 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. provm/events

ActiveProject

provm/events
============

Event handler for WebSocket

1.0.0(5y ago)07MITPHP

Since Mar 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Aldarien/events)[ Packagist](https://packagist.org/packages/provm/events)[ RSS](/packages/provm-events/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Events
======

[](#events)

[WebSockets](https://en.wikipedia.org/wiki/WebSocket) app for PHP. Using [Ratchet](http://socketo.me/) as a base for creating the **app** it can be used as **framework** for connecting to the database from the web **UI**.

Introduction
------------

[](#introduction)

I wrote this project because I had a hard time finding any alternative to handling Server-Side WebSocket with [PHP](http://php.net). [Ratchet](http://socketo.me/) handles the connection but not the **app** itself. I needed an app structure similar to [Slim](https://slimframework.com) which was what I work with. This is the result.

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

[](#installation)

Use [composer](https://getcomposer.org).

```
composer require aldarien/events

```

Use
---

[](#use)

I recommend you setup your **app** with a Container like [PHP-DI](https://php-di.org/)

*Base example*:

```
$app = ProVM\Common\Alias\Server\App::factory(
  new Ratchet\Server\HttpServer(
    new Ratchet\Server\WsServer(
      new ProVM\Common\Alias\Event\Message(new SplObjectStorage())
    )
  ),
  $port ?? 8010
);
$app->add('event_name', function($request, $response) {
  // do action
  return $response;
})
$app->run();

```

*Breakdown*:

The **app** is created similar to [Ratchet](http://socketo.me/) with the wrapper `ProVM\Common\Alias\Server\App` but the message handler is from this package `ProVM\Common\Alias\Event\Message` which handles all event dispatches and listeners.

Then the event(s) are added with `$app->add` it requires a name for the event and a callable handler that work similar to [Slim](https://slimframework.com) Controllers.

Finally just `$app->run`

You can use a **Listener** for the callable:

```
class Handler {
  public function __invoke($request, $response) {
    // do something else
    return $response;
  }
  public function other($request, $response) {
    // other action
    return $response;
  }
}
$app->add('event2', new Handler());
$app->add('other', [new Handler(), 'other']);

```

In the web **UI** just create a websocket:

```
var conn = new WebSocket(websocket_url)
conn.onopen = function(e) {
  // open event
}
conn.onmessage = function(e) {
  // listen to messages received
}
conn.onerror = function(e) {
  console.error(e)
}
conn.onclose = function(e) {
  // check if e.code == 1000 closed without error)
}
msg = {
  action: 'event_name',
  data: []
}
conn.send(JSON.stringify(msg))

```

*Breakdown*:

Create the websocket connection `new WebSocket(websocket_url)` where `websocket_url` can be something like `ws://localhost:8010` or `wss://localhost:8010` where the port is the same one set in the app.

Set the event listeners for `open`, `message`, `error` and `close` and start sending messages with `send`

Take note of the last lines where the message received by the **app** needs an action equivalent to the event names added before and the data associated if any (can be missing).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

1875d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/031d3f5b37015f185e36a6579c589d8d063554af500f52b86c8c944ef5bab9ad?d=identicon)[Aldarien](/maintainers/Aldarien)

---

Top Contributors

[![Aldarien](https://avatars.githubusercontent.com/u/23040524?v=4)](https://github.com/Aldarien "Aldarien (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.3k86.3M2.2k](/packages/symfony-symfony)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

2.9k404.0M702](/packages/league-commonmark)[symfony/mailer

Helps sending emails

1.6k368.1M955](/packages/symfony-mailer)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)

PHPackages © 2026

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