The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Versions:

Getting Started

Events

Listeners

Generator

Class Based Events

The emitter accepts implementations of the EventInterface interface.

use League\Event\EventInterface;

class DomainEvent implements EventInterface
{
    public function getName()
    {
        return 'DomainEvent';
    }
    // Add domain methods here
}

$emitter->addListener('DomainEvent', function ($event) {
    echo $event->getName(); // echo's "DomainEvent"
});

$emitter->emit(new DomainEvent);

AbstractEvent

The package also provides an abstract class which provides a default getName implementation returning the FQCN.