flamecore/event-observer

This package is abandoned and no longer maintained. No replacement package was suggested.

Watch events and react to them

v1.0.0 2015-08-03 13:47 UTC

This package is not auto-updated.

Last update: 2021-03-18 00:14:41 UTC


README

Latest Stable Build Status Scrutinizer Coverage License

This library allows you to watch events and react to them.

Usage instructions and more information can be found in our Wiki.

Getting Started

Create a new Responder object which holds the event listeners:

$responder = new Responder();
$responder->setListener('action.event', function (array $data, $event) {
    print_r($data);
});

Create a new Observer object and give it some actions to react to:

$observer = new Observer();
$observer->addResponder('action', $responder);

Notify the Observer of events (optionally with data):

$observer->notify('action.event');
$observer->notify('action.event', ['some_data' => 123.4]);

Installation

Install via Composer

Create a file called composer.json in your project directory and put the following into it:

{
    "require": {
        "flamecore/event-observer": "1.0.*"
    }
}

Install Composer if you don't already have it present on your system:

$ curl -sS https://getcomposer.org/installer | php

Use Composer to download the vendor libraries and generate the vendor/autoload.php file:

$ php composer.phar install

Include the vendor autoloader and use the classes:

namespace Acme\MyApplication;

use FlameCore\EventObserver\Observer;
use FlameCore\EventObserver\Responder\Responder;

require_once 'vendor/autoload.php';

Requirements

  • You must have at least PHP version 5.4 installed on your system.

Contributors

If you want to contribute, please see the CONTRIBUTING file first.

Thanks to the contributors:

  • Christian Neff (secondtruth)