Skip to content

Installation

Muhammet Şafak edited this page May 24, 2026 · 1 revision

Installation

initphp/events is distributed exclusively through Composer.

Requirements

Requirement Notes
PHP >= 5.6 The library ships pure PHP and uses only microtime, call_user_func_array, array_* and a handful of other built-ins available since 5.x.
Composer Any reasonably recent version.

No PHP extensions, no third-party dependencies, no autoloading magic beyond PSR-4.

Install

composer require initphp/events

That single command:

  1. Adds the package to your composer.json.
  2. Registers the PSR-4 namespace InitPHP\Events\ against vendor/initphp/events/src/.
  3. Autoloads src/aliases.php so legacy InitPHP\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.

Verify the install

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.

Upgrading

The library follows SemVer. Major versions can introduce breaking changes (see the Migration Guide for the 1.x → 2.x notes). Minor and patch releases keep the public surface backwards-compatible.

composer update initphp/events

Composer constraint examples

{
    "require": {
        "initphp/events": "^2.0"
    }
}

If you are still on PHP 5.6/7.x and want to lock to a 1.x line, use:

{
    "require": {
        "initphp/events": "^1.0"
    }
}

The 1.x line lacks the bundled low-level EventEmitter; use 2.x whenever your PHP version allows.

Uninstall

composer remove initphp/events

Clone this wiki locally