-
Notifications
You must be signed in to change notification settings - Fork 0
/
rr-worker.php
29 lines (24 loc) · 995 Bytes
/
rr-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
<?php
ini_set('display_errors', 'stderr');
require __DIR__ . '/vendor/autoload.php';
$relay = new Spiral\Goridge\StreamRelay(STDIN, STDOUT);
$psr7 = new Spiral\RoadRunner\PSR7Client(new Spiral\RoadRunner\Worker($relay));
$app = new Monyxie\Mdir\Application();
while ($request = $psr7->acceptRequest()) {
try {
$symfonyResponse = $app->handle(Symfony\Component\HttpFoundation\Request::create(
$request->getUri(),
$request->getMethod(),
$request->getQueryParams(),
$request->getCookieParams(),
$request->getUploadedFiles(),
$request->getServerParams(),
$request->getBody()
));
$resp = new Zend\Diactoros\Response('php://memory', $symfonyResponse->getStatusCode(), $symfonyResponse->headers->all());
$resp->getBody()->write($symfonyResponse->getContent());
$psr7->respond($resp);
} catch (\Throwable $e) {
$psr7->getWorker()->error((string)$e);
}
}