2017 © Pedro Peláez
 

library event-data

Abstracts event data handling

image

michaelesmith/event-data

Abstracts event data handling

  • Thursday, May 25, 2017
  • by michaelesmith
  • Repository
  • 1 Watchers
  • 0 Stars
  • 52 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

README

What is it?

This is a library that allows for easy abstraction of event data collection and storage, allowing it to be stored locally or external service.., (*2)

Installation

Get Composer at http://getcomposer.org, (*3)

php composer.phar require "michaelesmith/event-data" "dev-master"

Examples

This isn't very useful in production to store the events in a local file but might be useful during configuration. You can also configure loggers., (*4)

$edm = new \MS\EventData\EventDataManager(new \MS\EventData\Storage\File('/tmp/events.txt'));
$edm->addLogger(new \MS\EventData\Logger\GenericLogger());
$edm->store(new \MS\EventData\Event\Event('collection', ['field1' => 'val1']));

By default it will send the event immediately but this can be configured., (*5)

$edm->setDelayed(true);

$edm->store(new \MS\EventData\Event\Event('collection', ['field1' => 'val1']));
...
$edm->store(new \MS\EventData\Event\Event('collection', ['field1' => 'val1']));
...

$edm->flush();

In this example the events are not sent to the storage until flush is called., (*6)

You can also put it in debug mode so events are logged but never sent to storage., (*7)

$edm->setDebug(true);

$edm->store(new \MS\EventData\Event\Event('collection', ['field1' => 'val1']));

Finally a useful example. Here we send the event data to KeenIO and log with PSR logger like Monolog., (*8)

$edm = new \MS\EventData\EventDataManager(new \MS\EventData\Storage\KeenIO($keenClient));
$edm->addLogger(new \MS\EventData\Logger\PSRLogger($monolog, $edm));
$edm->setDebug(DEBUG_MODE);
$edm->setDelayed(true);

...
$edm->store(new \MS\EventData\Event\Event('collection', ['field1' => 'val1']));
...

$edm->flush(); //after the response has been returned to the user

The Versions

25/05 2017

dev-master

9999999-dev https://github.com/michaelesmith/EventData

Abstracts event data handling

  Sources   Download

MIT

The Requires

  • php >=5.4

 

event event data