PHPackages                             romeoz/rock-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. romeoz/rock-events

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

romeoz/rock-events
==================

A simple implementation of Pub/Sub for PHP

0.11.0(10y ago)24.9k7MITPHPPHP &gt;=5.4.0

Since Jan 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/romeOz/rock-events)[ Packagist](https://packagist.org/packages/romeoz/rock-events)[ RSS](/packages/romeoz-rock-events/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (7)

Implementation of Publisher-Subscriber for PHP
==============================================

[](#implementation-of-publisher-subscriber-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/c920b4a1f75f1f2480a754746c258d5d228f9c7e996c2232a53c0b02a7d72b38/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d6576656e74732f762f737461626c652e737667)](https://packagist.org/packages/romeOz/rock-events)[![Total Downloads](https://camo.githubusercontent.com/b5a33515afc394518f80ee25cb364aa0b14d43b67eb505d81848011e0fb3ab90/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d6576656e74732f646f776e6c6f6164732e737667)](https://packagist.org/packages/romeOz/rock-events)[![Build Status](https://camo.githubusercontent.com/0535775462b42cb9b31527c09a6f8a9bc2fe2258ff4efef51e033e89485241e7/68747470733a2f2f7472617669732d63692e6f72672f726f6d654f7a2f726f636b2d6576656e74732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/romeOz/rock-events)[![HHVM Status](https://camo.githubusercontent.com/2384e5a4b5a7a98c5f0c1406324aee1e81f13fedbb0c25be0e8023ab56e46c51/687474703a2f2f6868766d2e683463632e64652f62616467652f726f6d656f7a2f726f636b2d6576656e74732e737667)](http://hhvm.h4cc.de/package/romeoz/rock-events)[![Coverage Status](https://camo.githubusercontent.com/46263fd97e938c345860218b911f4d37bfb93416eaebcf1435ed93e5b6d27b7f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f726f6d654f7a2f726f636b2d6576656e74732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/romeOz/rock-events?branch=master)[![License](https://camo.githubusercontent.com/fdbfacb8aa1ae2a82d7e9520e19fbb6ebe0d56cc8248fb48576d4fe2fb4b6e8b/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d6576656e74732f6c6963656e73652e737667)](https://packagist.org/packages/romeOz/rock-events)

Features
--------

[](#features)

- Handler can be a closure, instance, and static class
- Standalone module/component for [Rock Framework](https://github.com/romeOz/rock)

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

[](#installation)

From the Command Line:

```
composer require romeoz/rock-events

```

In your composer.json:

```
{
    "require": {
        "romeoz/rock-events": "*"
    }
}
```

Quick Start
-----------

[](#quick-start)

```
use rock\events\Event;

class Foo
{
    public $str = 'Rock!';
}

$object = new Foo();
$eventName = 'onAfter';
$handler = function (Event $event) {
    echo "Hello {$event->owner->str}";
};

Event::on($object, $eventName, $handler);

Event::trigger($object,  'onAfter'); // output: Hello Rock!
```

Documentation
-------------

[](#documentation)

\####on(string|object $class, string $name, callable $handler)

To subscribe to the event.

Set a handler can be as follows:

```
$handler = function (Event $event) {
    echo "Hello Rock!";
};
Event::on(new Foo, 'onAfter', $handler);
```

Options:

- `function (Event $event) { ... }`
- `[new Foo, 'method']`
- `['Foo', 'static_method']`

\####trigger(string|object $class, string $name, Event $event = null)

To publish event.

```
Event::trigger(new Foo,  'onEvent');

// or

Event::trigger('test\Foo',  'onEvent');
```

\####off(string|object $class, string $name, callable $handler = null)

Detach event.

```
$handler =
    function (Event $event) {
        echo 'Hello Rock!'
    };
$instance =  new Foo;
Event::on($instance, 'onAfter', $handler);

Event::off($instance, 'onAfter');
```

Requirements
------------

[](#requirements)

- **PHP 5.4+**

License
-------

[](#license)

The Rock Events is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community14

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

Every ~40 days

Total

8

Last Release

3838d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23c5d84a59845d751cb69f5469986579b9312c54c898b366fefdc05baaa80a9c?d=identicon)[romeOz](/maintainers/romeOz)

---

Top Contributors

[![romeOz](https://avatars.githubusercontent.com/u/3135712?v=4)](https://github.com/romeOz "romeOz (42 commits)")

---

Tags

eventpubsubpublish-subscribe

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/event-manager

The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.

6.1k501.1M115](/packages/doctrine-event-manager)[league/event

Event package

1.6k141.6M184](/packages/league-event)[laminas/laminas-eventmanager

Trigger and listen to events within a PHP application

1.0k69.8M225](/packages/laminas-laminas-eventmanager)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)[spatie/laravel-event-sourcing

The easiest way to get started with event sourcing in Laravel

9003.7M26](/packages/spatie-laravel-event-sourcing)[spatie/laravel-google-calendar

Manage events on a Google Calendar

1.4k1.5M21](/packages/spatie-laravel-google-calendar)

PHPackages © 2026

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