PHPackages                             locky42/leopard-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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. locky42/leopard-events

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

locky42/leopard-events
======================

A library for handling PSR-14 events.

1.1.1(1mo ago)0144MITPHPPHP &gt;=8.3

Since Oct 25Pushed 1mo agoCompare

[ Source](https://github.com/locky42/leopard-events)[ Packagist](https://packagist.org/packages/locky42/leopard-events)[ RSS](/packages/locky42-leopard-events/feed)WikiDiscussions main Synced 1mo ago

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

Leopard Events
==============

[](#leopard-events)

`locky42/leopard-events` is a lightweight PSR-14 style event library for PHP 8.3+.

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

[](#installation)

```
composer require locky42/leopard-events
```

Core Classes
------------

[](#core-classes)

- `EventManager` — static facade for registering/removing/dispatching listeners
- `ListenerProvider` — in-memory listener storage with priority sorting
- `EventDispatcher` — dispatch pipeline implementation

Event Registration
------------------

[](#event-registration)

You can register a listener by:

1. **Event object** (stores payload template)
2. **Event class string** (no object instantiation at registration time)

```
use Leopard\Events\EventManager;

class MyEvent {
    public function __construct(public ?object $obj = null) {}
    public bool $handled = false;
}

// Object registration
EventManager::addEvent(new MyEvent(), function (MyEvent $event) {
    $event->handled = true;
});

// Class-string registration (safe even if constructor has required args)
EventManager::addEvent(MyEvent::class, function (MyEvent $event) {
    $event->handled = true;
});
```

Dispatching
-----------

[](#dispatching)

Dispatch by class name:

```
$event = EventManager::doEvent(MyEvent::class);
```

Or pass constructor arguments:

```
$payload = new \stdClass();
$payload->value = 10;

$event = EventManager::doEvent(MyEvent::class, $payload);
```

Shared Event State Between Listeners
------------------------------------

[](#shared-event-state-between-listeners)

When dispatching, listeners for the same event class receive the same event instance in the dispatch cycle. Mutations made by one listener are visible to subsequent listeners.

```
EventManager::addEvent(MyEvent::class, function (MyEvent $event) {
    $event->handled = true;
});

EventManager::addEvent(MyEvent::class, function (MyEvent $event) {
    // sees handled === true
});
```

Listener Priority
-----------------

[](#listener-priority)

`addEvent(..., $priority)` supports integer priorities.

```
EventManager::addEvent(MyEvent::class, $firstListener, -100);
EventManager::addEvent(MyEvent::class, $secondListener, 0);
EventManager::addEvent(MyEvent::class, $thirdListener, 100);
```

Listeners are sorted by priority before dispatch.

Removing and Clearing Listeners
-------------------------------

[](#removing-and-clearing-listeners)

```
EventManager::removeEvent(new MyEvent(), $listener);
EventManager::getProvider()->clearListeners();
```

`removeEvent` requires an event object (not class string).

Testing
-------

[](#testing)

```
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance89

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

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

Total

3

Last Release

55d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72bf088ea009ca7340ddb130d80d71a31ad8726ab71133a176e38326600696bb?d=identicon)[locky42](/maintainers/locky42)

---

Top Contributors

[![locky42](https://avatars.githubusercontent.com/u/57048956?v=4)](https://github.com/locky42 "locky42 (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/type-resolver

A PSR-5 based resolver of Class names, Types and Structural Element Names

9.2k719.5M166](/packages/phpdocumentor-type-resolver)[symfony/contracts

A set of abstractions extracted out of the Symfony components

3.9k64.6M103](/packages/symfony-contracts)[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M342](/packages/league-container)[stella-maris/clock

A pre-release of the proposed PSR-20 Clock-Interface

7947.5M2](/packages/stella-maris-clock)

PHPackages © 2026

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