PHPackages                             phower/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phower/events

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phower/events
=============

Events oriented programming for PHP.

1.1.0(9y ago)014MITPHPPHP ^5.6 || ^7.0

Since Apr 8Pushed 9y ago1 watchersCompare

[ Source](https://github.com/phower/events)[ Packagist](https://packagist.org/packages/phower/events)[ RSS](/packages/phower-events/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Phower Events
=============

[](#phower-events)

Events oriented programming for PHP.

Requirements
------------

[](#requirements)

Phower Events requires:

- [PHP 5.6](http://php.net/releases/5_6_0.php) or above; version [7.0](http://php.net/releases/7_0_0.php) is recommended

Instalation
-----------

[](#instalation)

Add Phower Events to any PHP project using [Composer](https://getcomposer.org/):

```
composer require phower/events
```

Usage
=====

[](#usage)

This package provides an event-oriented mechanism which allows any PHP application to implement a way for separated parts to communicate with each other by dispatching events and listening to them.

An implementation of PhowerEvents requires an EventHandler class and at least an event listener which must be any valud [PHP callable](http://php.net/manual/en/language.types.callable.php):

```
use Phower\Events\EventHandlerInterface;
use Phower\Events\EventInterface;

class MyEventListener
{
    public onDummyEvent(EventInterface $event, EventHandlerInterface $handler)
    {
        print_r($event->getName());
        print_r($handler->getListeners($event));
    }
}
```

> Note that any listener method should always expect two arguments:
>
> 1. An instance of `EventInterface`, representing the event triggered;
> 2. An intance of `EventHandlerInterface`, the handler which have triggered that event.

Before being able to trigger the listner above we must to attach it to an handler instance:

```
use Phower\Events\EventHandler;

$handler = new EventHandler();
$handler->addListener('dummy', 'MyEventListener::onDummyEvent');

// later at any point where the handler is available:
$handler->trigger('dummy');
```

### Container aware handlers

[](#container-aware-handlers)

When a [Container](https://github.com/phower/container) is part of an application it may be useful to automatically pass it across the listeners.

For this situation we can switch to an instance of [ContainerAwareEventHandlerInterface](src/ContainerAwareEventHandlerInterface.php)and make our listeners also instances of [ContainerAwareInterface](https://github.com/phower/container/blob/master/src/ContainerAwareInterface.php).

Running Tests
-------------

[](#running-tests)

Tests are available in a separated namespace and can run with [PHPUnit](http://phpunit.de/)in the command line:

```
vendor/bin/phpunit
```

Coding Standards
----------------

[](#coding-standards)

Phower code is written under [PSR-2](http://www.php-fig.org/psr/psr-2/) coding style standard. To enforce that [CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) tools are also provided and can run as:

```
vendor/bin/phpcs
```

Reporting Issues
----------------

[](#reporting-issues)

In case you find issues with this code please open a ticket in Github Issues at .

Contributors
------------

[](#contributors)

Open Source is made of contribuition. If you want to contribute to Phower please follow these steps:

1. Fork latest version into your own repository.
2. Write your changes or additions and commit them.
3. Follow PSR-2 coding style standard.
4. Make sure you have unit tests with full coverage to your changes.
5. Go to Github Pull Requests at and create a new request.

Thank you!

Changes and Versioning
----------------------

[](#changes-and-versioning)

All relevant changes on this code are logged in a separated [log](CHANGELOG.md) file.

Version numbers follow recommendations from [Semantic Versioning](http://semver.org/).

License
-------

[](#license)

Phower code is maintained under [The MIT License](https://opensource.org/licenses/MIT).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Total

2

Last Release

3320d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/04e91a806958f09ca8b3f4c24c6f5c4bcbce3c4e44dd882fa1e4c737ee7774c6?d=identicon)[pedrobrazao](/maintainers/pedrobrazao)

---

Tags

phpeventsphower

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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