Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
/ eveniment Public archive

Eveniment is a simple event dispatching PHP library

Notifications You must be signed in to change notification settings

iosifch/eveniment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eveniment

Eveniment is a simple event dispatcher library for PHP. It's highly inspired by igorw/evenement library.

Build Status

Install

Eveniment can be installed via composer running the command below:

composer require eveniment/eveniment

Or fetching from the Github repository:

git clone [email protected]:iosifch/eveniment.git

Test

Just run vendor/bin/phpunit and look at the green bar:)

Usage

Firstly, create the dispatcher event:

<?php

$dispatcher = new Eveniment\EventDispatcher();

Attach a simple subscriber to an event and after raise the event:

<?php

$dispatcher->on('event.name', function($name) {
    echo $name;
});
$dispatcher->dispatch('event.name', ['Jon']);

You can set the subscriber priority also. However, the default priority is 1000:

<?php

// This will be the last one called because the lower priority
$dispatcher->on('event.name', ['vendor\library\Class', 'onEventRaise'], 5);
// This subscriber will be the first one called because it has priority set to 1000
$dispatcher->on('event.name', function() {});

About

Eveniment is a simple event dispatching PHP library

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages