gamegos/events

Library to implement event emitting capability

Installs: 800

Dependents: 1

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 1

Open Issues: 0

pkg:composer/gamegos/events

2.0.0-beta1 2025-11-04 16:44 UTC

This package is auto-updated.

Last update: 2025-12-04 17:00:12 UTC


README

License Tests

Simple library to implement event emitting capability for PHP applications.

Installation

Install via Composer

Run the following command in the root directory of your project:

composer require gamegos/events:*

Basic Usage

$eventManager = new Gamegos\Events\EventManager();
// Attach a callback to an event named 'foo'.
$eventManager->attach(
    'foo',
    function (Gamegos\Events\EventInterface $e) {
        echo sprintf('Handled "%s" event with subject "%s".', $e->getName(), $e->getSubject());
    }
);
// Trigger the 'foo' event with a subject ('bar').
$eventManager->trigger('foo', 'bar');

The above example will output:

Handled "foo" event with subject "bar".