-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.php
45 lines (35 loc) · 1.02 KB
/
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
40
41
42
43
44
45
<?php
declare (strict_types = 1);
use League\Route\Router;
use Spiral\RoadRunner\PSR7Client;
use App\Providers\AppServiceProvider;
use Infrastructure\Http\AbstractExceptionHandler;
use Infrastructure\Providers\InfrastructureServiceProvider;
ini_set('display_errors', 'stderr');
include 'vendor/autoload.php';
/**
* @var \League\Container\Container
*/
$container = require 'src/infrastructure/container.php';
$container
->addServiceProvider(InfrastructureServiceProvider::class)
->addServiceProvider(AppServiceProvider::class);
/**
* @var \Spiral\RoadRunner\PSR7Client
*/
$psr7 = $container->get(PSR7Client::class);
/**
* @var \League\Route\Router
*/
$router = $container->get(Router::class);
/**
* @var \Infrastructure\Http\AbstractExceptionHandler
*/
$exceptionHandler = $container->get(AbstractExceptionHandler::class)->getHandler();
while ($req = $psr7->acceptRequest()) {
try {
$psr7->respond($router->dispatch($req));
} catch (Throwable $e) {
$psr7->respond($exceptionHandler($e));
}
}