Skip to content

mulertech/event-manager

Repository files navigation

EventManager


Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status Total Downloads Test Coverage


The MulerTech EventManager package is a simple event manager that allows you to register and trigger events in your PHP application.


Installation

  1. Add to your "composer.json" file into require section:
"muler/event-manager": "^1.0"

and run the command:

php composer.phar update
  1. Run the command:
php composer.phar require muler/event-manager "^1.0"

Usage


Registering an event
use Muler\EventManager\EventManager;

$eventManager = new EventManager();

$eventManager->addListener(new Listener());

// Into the class that calls the event
$eventManager->dispatch(new Event());
Creating a listener
use Muler\EventManager\ListenerInterface;

class Listener implements ListenerInterface
{
    public function handle(Event $event)
    {
        // Do something
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages