-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.php
39 lines (25 loc) · 959 Bytes
/
worker.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
37
38
39
<?php
declare(strict_types=1);
use Core\Builder\AppBuilderManager;
use Core\Builder\Factories\ContainerFactory;
use Core\Http\Factories\RequestFactory;
require __DIR__ . '/configs/bootstrap.php';
$containerFactory = new ContainerFactory();
$containerFactory
// Set to true in production
->enableCompilation(false);
$container = $containerFactory->get();
$appBuilder = new AppBuilderManager($container);
$requestFactory = new RequestFactory();
$request = $requestFactory->createRequest();
$app = $appBuilder->build($request);
/** @var Spiral\RoadRunner\Http\PSR7WorkerInterface $psr7Worker */
$psr7Worker = $app->getContainer()->get(Spiral\RoadRunner\Http\PSR7WorkerInterface::class);
while ($req = $psr7Worker->waitRequest()) {
try {
$res = $app->handle($req);
$psr7Worker->respond($res);
} catch (Throwable $e) {
$psr7Worker->getWorker()->error((string) $e);
}
}