spiral / roadrunner
- вторник, 2 октября 2018 г. в 00:15:51
Go
High-performance PHP application server, load-balancer and process manager written in Golang
RoadRunner is an open source (MIT licensed), high-performance PHP application server, load balancer and process manager. It supports running as a service with the ability to extend its functionality on a per-project basis.
RoadRunner includes PSR-7 compatible HTTP/HTTPS server and can be used to replace classic Nginx+FPM setup with much greater performance.
<?php
ini_set('display_errors', 'stderr');
include "vendor/autoload.php";
$relay = new Spiral\Goridge\StreamRelay(STDIN, STDOUT);
$psr7 = new Spiral\RoadRunner\PSR7Client(new Spiral\RoadRunner\Worker($relay));
while ($req = $psr7->acceptRequest()) {
try {
$resp = new \Zend\Diactoros\Response();
$resp->getBody()->write("hello world");
$psr7->respond($resp);
} catch (\Throwable $e) {
$psr7->getWorker()->error((string)$e);
}
}
Configuration can be located in .rr.yaml
file:
http:
address: 0.0.0.0:8080
workers:
command: "php psr-worker.php"
pool:
numWorkers: 4
The MIT License (MIT). Please see LICENSE
for more information. Maintained by SpiralScout.