neovav/events

A PHP lib with notifier for events

dev-master 2019-08-18 19:25 UTC

This package is auto-updated.

Last update: 2024-05-26 21:58:44 UTC


README

This is sample how use Events libs with Notifier

Getting Started

Installation

For installations neovav/Events, run:

git clone https://github.com/neovav/Events
cd Events
composer install

Usage

use \neovav\Events\Subscriber;
use \neovav\Events\Notifier;
use \neovav\Events\INotice;
use \neovav\Events\Notice;
use \neovav\Events\IEventData;

require_once '..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';

$func = function (INotice $notice) {
    echo "\r\n", 'DEBUG          => ', $notice->getEventName();
    if ($notice->isEventData()) var_dump($notice->getEventData());
};

try {
    $subscr_dbg = new Subscriber('DEBUG@Start', $func);
    Notifier::attach($subscr_dbg);
} catch(Exception $e) {var_dump($e);};

$notice_dbg = new Notice(__FILE__,'DEBUG@Start');

Notifier::notify($notice_dbg);

Notifier::detach($subscr_dbg);

For more samples view in directory : samples Main file in samples: samples/sample.php