-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.php
More file actions
34 lines (27 loc) · 1.04 KB
/
server.php
File metadata and controls
34 lines (27 loc) · 1.04 KB
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
<?php declare(strict_types=1);
// This is the entry point for a high-performance application server like RoadRunner.
ini_set('display_errors', 'stderr');
// --- Bootstrap The Application ---
// The container is created once when the server worker starts.
require __DIR__.'/bootstrap/app.php';
use App\App;
use Spiral\RoadRunner;
$worker = RoadRunner\Worker::create();
$psrFactory = new RoadRunner\Http\PSR7Worker(
$worker,
new \Laminas\Diactoros\ServerRequestFactory(),
new \Laminas\Diactoros\StreamFactory(),
new \Laminas\Diactoros\UploadedFileFactory()
);
// --- Request Handling Loop ---
while ($request = $psrFactory->waitRequest()) {
try {
// Pass the request to the application kernel and get a response.
$response = \ACE\Foundation\App::getInstance()->handle($request);
// Send the response back to the server.
$psrFactory->respond($response);
} catch (\Throwable $e) {
// If something catastrophic happens, send an error response.
$psrFactory->getWorker()->error((string)$e);
}
}