Search by

localzet / events

localzet

In-process event dispatch with exact and prefix listeners.

Package info

github.com/localzet/Events

pkg:composer/localzet/events

Fund package maintenance!

localzet

Statistics

Installs: 279

Dependents: 0

Suggesters: 2

Stars: 21

Open Issues: 0

v1.0.0 2024-10-15 19:25 UTC

This package is auto-updated.

Last update: 2026-10-05 14:26:22 UTC


README

Русская документация

In-process event dispatch with exact and prefix listeners.

Status and compatibility

Listener exceptions are collected in emit() results. A false response stops propagation; halt returns the first non-null result.

Dependencies

  • php: >=8.0

Installation

composer require localzet/events

Example

require __DIR__ . '/vendor/autoload.php';

use localzet\Events;

$id = Events::on('user.*', static fn(array $data, string $event): string => $event);
$responses = Events::emit('user.created', ['id' => 1]);
Events::off('user.*', $id);

listeners() returns matching callbacks; list() returns registered listeners with their names and IDs. Exact and prefix listeners run in registration order. Class-based instance handlers must support construction without arguments; static callbacks are not instantiated.

Development checks

composer validate --strict
composer install
composer dump-autoload --optimize --strict-psr
composer lint
composer test

Installation, lint and autoload checks do not establish end-to-end behavior or production readiness.

Historical usage notes need verification against the current API.

Author and license

Ivan Zorin (localzet), creator@localzet.com, https://www.localzet.com. Source: https://github.com/localzet/Events. AGPL-3.0-or-later; LICENSE. Original copyright and third-party licenses remain applicable.

Authors · Contributing · Security