PHPackages                             bee4/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. bee4/events

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

bee4/events
===========

Basic event dispatcher definition, implement basic Mediator pattern

v1.1.0(10y ago)13.0k3Apache-2.0PHPPHP &gt;=5.4.0

Since Oct 3Pushed 10y ago1 watchersCompare

[ Source](https://github.com/bee4/events)[ Packagist](https://packagist.org/packages/bee4/events)[ RSS](/packages/bee4-events/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (11)Used By (3)

Bee4 / Events v1.1.0
====================

[](#bee4--events-v110)

[![Build Status](https://camo.githubusercontent.com/56341bf781a396a250b487ab51f8182366737ff63d693d474c5dd70c79019796/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f626565342f6576656e74732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bee4/events)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c720419b728e7221ba8b99c4200ae6e49519fad7a766af4abebd2da86494eae6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f626565342f6576656e74732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bee4/events/?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/e9dbcc957bb0089fb3484e7ba889509b75575423129a64a394811985cadc9a5f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f626565342f6576656e74732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bee4/events/)[![SensiolabInsight](https://camo.githubusercontent.com/24762ddeca140416f1cd474e613ecdc1dc7ae518a09cc9fc146f56b2831bb5d7/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f66303666663162612d343061352d343833622d383863652d6333376231303137376232632e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/f06ff1ba-40a5-483b-88ce-c37b10177b2c)

[![License](https://camo.githubusercontent.com/293e0d19536d9cecef405b61d70fe6456ee6cdc80608d022d3f1383b1345e9be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626565342f6576656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bee4/events)

The main goal of this code is to allow using Event Dispatcher pattern with different popular implementations :

- [Symfony 2 Event Dispatcher](http://symfony.com/doc/current/components/event_dispatcher/introduction.html) component
- [Événment Event Emittter](https://github.com/igorw/evenement) component
- [League Event](http://event.thephpleague.com/) component

This library does not intend to provide the whole possibilities of each adapters but a standard couple of interface which allow to do not depend from one vendor. This way, you can use your preferred event system with one of the `bee4/events` lib user.

Installing
----------

[](#installing)

[![Latest Stable Version](https://camo.githubusercontent.com/34ca03058d09405bcb0289a0f94c03876efeb7114bf0b325343d098679758883/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626565342f6576656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bee4/events)[![Total Downloads](https://camo.githubusercontent.com/70d10fe8796d57e198a10d2eecd1efdddf91f75fb8b68f7b33a14593603904fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f626565342f6576656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bee4/events)

This project can be installed using Composer. Add the following to your composer.json:

```
{
    "require": {
        "bee4/events": "~1.1"
    }
}
```

or run this command:

```
composer require bee4/events:~1.1
```

Event System
------------

[](#event-system)

### DispatcherInterface

[](#dispatcherinterface)

Define how an object must trigger an event. It contains 4 methods :

- `dispatch` to trigger an EventInterface instance
- `on` to attach a listener
- `once` to attach a listener that will be ran then detached
- `remove` to remove a given listener
- `get` to retrieve all listeners attached to one event name

\###DispatcherAwareInterface Define how an object can rely to a dispatcher to handle events. It contains 4 methods :

- `setDispatcher` to initialize the current `DispatcherInterface`
- `getDispatcher` to retrieve the current `DispatcherInterface`
- `hasDispatcher` to check if there is a current `DispatcherInterface`
- `dispatch` to dispatch an `EventInterface` on the link `DispatcherInterface` if there is one...

### EventInterface

[](#eventinterface)

Define an event object which can be triggered. There is no default behaviour for this kind of object because an event can be really specific.

Adapters
--------

[](#adapters)

I hope you don't want to create your own dispatcher because there are some cool stuff overhere. There are adapters classes located in the `Bee4\Events\Adapters` namespace :

```
