-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathasync.php
More file actions
39 lines (28 loc) · 756 Bytes
/
async.php
File metadata and controls
39 lines (28 loc) · 756 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require __DIR__ . "/../vendor/autoload.php";
use AsyncInterop\Loop;
use AsyncPHP\Paper\Factory;
error_reporting(E_ERROR | E_PARSE);
// this too could be async...
$sample = file_get_contents(__DIR__ . "/sample.html");
Loop::execute(Amp\wrap(function() use ($sample) {
Loop::repeat(10, function() {
print ".";
});
$factory = new Factory();
$driver = $factory->createDriver([
"driver" => "webkit",
]);
$runner = $factory->createRunner([
"runner" => "amp",
]);
$promise = $driver
->body($sample)
->size("A4")
->orientation("portrait")
->dpi(300)
->render($runner);
$results = yield $promise;
print "done" . PHP_EOL;
Loop::stop();
}));