PHP code example of tcg / event-emitter

1. Go to this page and download the library: Download tcg/event-emitter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tcg / event-emitter example snippets




// create the emitter and set your glob deliminator
$emitter = new \TCG\Event\Emitter(':');

// some callable
$callable = function($event_slug, $foo=null, $bar=null){

	// do something here

}

// add a listener
$emitter->on('order:*', $callable);

// remove a listener
$emitter->off('order:*', $callable);

// remove all listeners for a given pattern
$emitter->off('order:*');

// emit an event
$emitter->emit('order:success', 123456, 22.86);





$app = new \Slim\Slim();

$app->add(new \TCG\Event\Middleware());