2017 © Pedro Peláez
 

library events

Small package to handle events

image

maer/events

Small package to handle events

  • Sunday, October 18, 2015
  • by maer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 204 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

A small event dispatcher for PHP

Need events? Here you go! No fuzz, no overcomplicated instantiation or bloated classes., (*1)

Install

Git clone or use composer to download the package with the following command:, (*2)

composer require maer/events 0.*

Usage

Include composers autoloader or include the files in the src/ folder manually. (start with the file EventInterface.php), (*3)

Create a new instance

$event = new Maer\Events\Event();

Add a listener

$event->addListener('start_something', 'some-id', function($name) {
    echo "Coolest ever: {$name}";
});

Trigger/Emit an event

$response = $event->emit('start_something', ['Chuck Norris']);

// Echoes: Coolest ever: Chuck Norris

Remove a listener

$event->removeListener('start_something', 'some-id');

Facade/Factory

If you don't want to store the Event class instance yourself, you can use the combined Facade/Factory class., (*4)

Use it as a Factory

This will always return the same instance, (*5)

$event = Maer\Events\EventFacade::getInstance();

To use it as a Facade

This will use the same instance as getInstance() returns so you can combine the two, (*6)

Maer\Events\EventFacade::addListener(...);

Maer\Events\EventFacade::removeListener(...);

$response = Maer\Events\EventFacade::emit(...);

//... and any other method available in the Event class

More...

Above is the basic usage but there is more... I'll update this guide soon., (*7)

The Versions

18/10 2015

dev-master

9999999-dev

Small package to handle events

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Magnus Eriksson

18/10 2015

dev-develop

dev-develop

Small package to handle events

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Magnus Eriksson

18/10 2015

0.1.0

0.1.0.0

Small package to handle events

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Magnus Eriksson