-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.php
36 lines (28 loc) · 983 Bytes
/
boot.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
32
33
34
35
36
<?php
use Psr\Http\Server\RequestHandlerInterface as Handler;
use Psr\Http\Message\ServerRequestInterface as Request;
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter as Emitter;
ignore_user_abort(true);
//
// Track backwards until we discover our composer.json.
//
for (
$root_path = dirname(__DIR__);
$root_path != '/' && !is_file($root_path . DIRECTORY_SEPARATOR . 'composer.json');
$root_path = realpath($root_path . DIRECTORY_SEPARATOR . '..')
);
if ($root_path) {
$running = TRUE;
$loader = require $root_path . '/vendor/autoload.php';
$hiraeth = new Hiraeth\Application($root_path);
$handler = function() use ($hiraeth) {
$hiraeth->run(function(Handler $handler, Request $request, Emitter $emitter) {
$emitter->emit($handler->handle($request));
});
};
$hiraeth->exec();
for ($requests = 0; $requests < ($_SERVER['MAX_REQUESTS'] ?? 100) && $running; ++$requests) {
$running = \frankenphp_handle_request($handler);
gc_collect_cycles();
}
}