generated from terremoth/php-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.php
31 lines (24 loc) · 799 Bytes
/
demo.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
30
31
<?php
require_once 'vendor/autoload.php';
use Terremoth\Async\Process;
use Terremoth\Async\PhpFile;
$process = new Process();
echo date('c') . ' :: Sending process. You should not wait any longer to see next message: ' . PHP_EOL;
try {
$process->send(function () {
sleep(5);
echo 123;
file_put_contents('demo.txt', 'Hello, World! At: ' . date('c'));
});
} catch (Exception $e) {
echo $e->getMessage();
}
echo date('c') . ' :: This is the next message' . PHP_EOL;
echo date('c') . ' :: Now let\'s process a file that takes a long time...' . PHP_EOL;
try {
$file = new PhpFile(__DIR__ . DIRECTORY_SEPARATOR . 'time-wasting-file.php');
$file->run();
echo date('c') . ' :: Ended...' . PHP_EOL;
} catch (Exception $e) {
echo $e->getMessage();
}