# EventEmitter **Repository Path**: wfdaj/EventEmitter ## Basic Information - **Project Name**: EventEmitter - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-10-26 - **Last Updated**: 2026-06-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # InitPHP EventEmitter > ## ⚠️ DEPRECATED — Use [`initphp/events`](https://github.com/InitPHP/Events) instead > > As part of the InitPHP package consolidation, **this package has been merged into [`initphp/events`](https://github.com/InitPHP/Events) starting with version 2.0.** The new package bundles the same `EventEmitter` primitive plus the higher-level `Events` / `Event` facade. > > This repository is kept read-only for historical reference. The final release (`1.0.1`) ships a bug fix for `EventEmitter::emit()` (see below) but **no further updates will be released**. > > ### Migration > > 1. Update your `composer.json`: > > ```diff > - "initphp/event-emitter": "^1.0", > + "initphp/events": "^2.0" > ``` > > 2. Your existing imports keep working: `initphp/events:^2.0` ships a `class_alias` so `\InitPHP\EventEmitter\EventEmitter` and `\InitPHP\EventEmitter\EventEmitterInterface` remain resolvable. > > 3. When you next touch the code, prefer the canonical namespace: > > ```php > // Before > use InitPHP\EventEmitter\EventEmitter; > > // After > use InitPHP\Events\EventEmitter; > ``` > > Composer declares a `replace` from `initphp/events:^2.0` to `initphp/event-emitter`, so the two packages will not be installed side-by-side. > > ### `emit()` bug fix in 1.0.1 > > Version `1.0.1` of this package contains a single bug fix in `EventEmitter::emit()`: the inner loop now correctly passes each individual `$listener` to `call_user_func_array`, instead of the surrounding `$listeners` array. Before this fix, emitted events fired no listeners. --- This library has been designed to emit events in its simplest and simplest form. ## Requirements - PHP 5.6 or higher ## Installation ``` composer require initphp/event-emitter ``` or **Manuel Installation :** Download this repository. And include the `src/Init.php` file in your project. ## Usage ```php require_once "vendor/autoload.php"; use InitPHP\EventEmitter\EventEmitter; $events = new EventEmitter(); $events->on('hello', function ($name) { echo 'Hello ' . $name . '!' . PHP_EOL; }, 99); $events->on('hello', function ($name) { echo 'Hi ' . $name . '!' . PHP_EOL; }, 10); // Emit $events->emit('hello', ['World']); ``` ## Credits - [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) <> ## License Copyright © 2022 [MIT License](./LICENSE)