Repository navigation
Installation
initphp/events is distributed exclusively through Composer.
| Requirement | Notes |
|---|---|
PHP ^8.2
|
Required by the package (composer.json). The library is plain PHP and uses only built-in functions such as microtime, call_user_func_array and array_*. |
| Composer | Any reasonably recent version. |
No PHP extensions, no third-party dependencies, no autoloading magic beyond PSR-4.
composer require initphp/eventsThat single command:
- Adds the package to your
composer.json. - Registers the PSR-4 namespace
InitPHP\Events\againstvendor/initphp/events/src/. - Autoloads
src/aliases.phpso legacyInitPHP\EventEmitter\*class names continue to resolve. See the Migration Guide for the full story.
Composer also honours the replace declaration in this package — it will
not install the deprecated initphp/event-emitter alongside it, even if
something in your dependency tree still asks for it.
A one-line smoke test:
<?php
require __DIR__ . '/vendor/autoload.php';
\InitPHP\Events\Events::on('boot', function () { echo "ok\n"; });
\InitPHP\Events\Events::trigger('boot');$ php smoke.php
ok
If you see ok, the autoloader resolved the classes and the package is
ready to use. Continue to Quick Start.
The library follows SemVer. Major versions can introduce breaking changes (see the Migration Guide for the 1.x → 2.x notes and the PHP 8.2 requirement). Minor and patch releases keep the public surface backwards-compatible.
composer update initphp/events{
"require": {
"initphp/events": "^3.0"
}
}If you are on a PHP version older than 8.2, the newest release that supports it
is 2.1.0 (its composer.json requires PHP >=5.6); 3.0.0 raises the
minimum to PHP 8.2 and is a breaking change (see the
Changelog). Lock to
the 2.1 line with:
{
"require": {
"initphp/events": "^2.1"
}
}The 1.x line (^1.0) lacks the bundled low-level EventEmitter
and the priority fixes described in the Migration Guide.
composer remove initphp/eventsinitphp/events · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
Core APIs
EventsfacadeEventEmitter- Listeners & Priorities
- Once-Listeners & Removal
- Stopping Propagation
- Simulate & Debug Mode
Practical
Reference