forked from PHPFluent/EventManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample-5.php
More file actions
25 lines (19 loc) · 707 Bytes
/
sample-5.php
File metadata and controls
25 lines (19 loc) · 707 Bytes
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
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use PHPFluent\EventManager\Manager;
use PHPFluent\EventManager\Listener\Process;
// Create a process to be executed in background.
// Parameter can be callable or Arara\Process\Action\Action instance.
$process = new Process(function () {
echo "-process.start: " . date('H:i:s') . PHP_EOL;
sleep(5);
echo "-process...end: " . date('H:i:s') . PHP_EOL;
});
$manager = new Manager();
$manager->addEventListener('process', $process);
// dispatch a non-blocking execution
$manager->dispatchEvent('process');
// continue executing
echo '* Script Execution Continued...' . PHP_EOL;
sleep(1.5);
echo '* Script Execution Finished!' . PHP_EOL;