PHPackages                             earc/event-tree - 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. earc/event-tree

ActiveLibrary

earc/event-tree
===============

eArc - the explicit architecture framework - event tree component

2.1(5y ago)0124↓75%2MITPHPPHP ^7.3 || ^8.0CI failing

Since Jul 17Pushed 5y agoCompare

[ Source](https://github.com/Koudela/eArc-eventTree)[ Packagist](https://packagist.org/packages/earc/event-tree)[ RSS](/packages/earc-event-tree/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (5)Versions (7)Used By (2)

eArc-eventTree
==============

[](#earc-eventtree)

Developer of PHP-applications might know the debug hell that lives right beside the massive use of event-listeners. The fancy thing is most JS-developer do not know this pain, although JS-Code is often heavy loaded with event-listeners. Some people suspect the major difference is the DOM. JS-developer always have a picture where the event-listeners hook in.

To enrich the PHP-community by this advantage I have developed the observer tree pattern/architecture which is in fact a combination of the composite and observer pattern and acts as architectural base for the eArc eventTree package.

It can be used as an easy way to expose lifecycle hooks (an incredible powerful tool in a collaborative workflow), to implement complex iterators, the broker, the chain of responsibility or the strategy pattern, MVC/ADR and many more.

As of all eArc packages one of its driving ideas is to make your code as explicit and easy to understand as possible without imposing to much restrictions on it.

Table of contents
-----------------

[](#table-of-contents)

- [Install](#install)
- [Bootstrap](#bootstrap)
- [Configure](#configure)
- [Basic usage](#basic-usage)
    - [The observer tree](#the-observer-tree)
    - [The listener](#the-listener)
    - [The event](#the-event)
    - [The propagation type](#the-propagation-type)
    - [Dispatching events](#dispatching-events)
- [Advanced usage](#advanced-usage)
    - [Patience](#patience)
    - [Listening to specific traveling phases](#listening-to-specific-traveling-phases)
    - [Manipulating the traveling of dispatched events](#manipulating-the-traveling-of-dispatched-events)
    - [Custom events](#custom-events)
    - [Subsystem handling](#subsystem-handling)
    - [Extending (third party) observer trees](#extending-third-party-observer-trees)
    - [The redirect directive](#the-redirect-directive)
    - [The lookup directive](#the-redirect-directive)
    - [Performance optimization](#performance-optimization)
    - [The view tree tool](#the-view-tree-tool)
- [Conclusion](#conclusion)
- [Releases](#releases)
    - [Release 2.1](#release-21)
    - [Release 2.0](#release-20)
    - [Release 1.1](#release-11)
    - [Release 1.0](#release-10)
    - [Release 0.0](#release-00)

Install
-------

[](#install)

```
composer install earc/event-tree
```

Bootstrap
---------

[](#bootstrap)

earc/event-tree uses [earc/di](https://github.com/Koudela/eArc-di) for dependency injection and [earc/core](https://github.com/Koudela/eArc-core) for the configuration file.

```
use eArc\Core\Configuration;
use eArc\DI\DI;

DI::init();
Configuration::build();
```

Place the above code in the section where your script/framework is bootstrapped or your `index.php`.

Configure
---------

[](#configure)

Put a file named `.earc-config.php` beneath the vendor dir. Its the configuration file for all the earc components.

```
