-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathevents_quickstart.php
29 lines (23 loc) · 1.12 KB
/
events_quickstart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* ---------------------------------------------------------------------------------------------------------------------
* DESCRIPTION
* ---------------------------------------------------------------------------------------------------------------------
* This file contains the example of using events with EventEmitter.
*
* ---------------------------------------------------------------------------------------------------------------------
* USAGE
* ---------------------------------------------------------------------------------------------------------------------
* To run this example in CLI from project root use following syntax
*
* $> php ./example/events_quickstart.php
*
* ---------------------------------------------------------------------------------------------------------------------
*/
require_once __DIR__ . '/bootstrap/autoload.php';
use Dazzle\Event\EventEmitter;
$emitter = new EventEmitter();
$emitter->on('script.start', function($user, $time) {
echo "User '$user' has started this script at $time.\n";
});
$emitter->emit('script.start', [ get_current_user(), date('H:i:s Y-m-d') ]);