RoadRunner can be installed and used in production right away for even the biggest applications under constant load.
RoadRunner utilizes goroutines and the multi-threading capabilities of Golang to bring maximum performance to PHP applications.
You can download or compile RoadRunner binaries that work on Mac OS, Windows, Linux, FreeBSD, and ARM.
RoadRunner provides a flexible framework that allows you to integrate any Golang library with your application using Goridge RPC protocol.
RoadRunner supports effective application, server and protocol error handling. You can also connect custom handlers or reporters like Sentry, Prometheus, etc.
RoadRunner offers a versatile foundation library that allows for running your application under HTTP/2, gRPC, Queue, etc.
A simple guide to using RoadRunner
To get the roadrunner binary file you can use our docker image: spiralscout/roadrunner:2.X.X (more information about image and tags can be found here) or use the GitHub package: ghcr.io/roadrunner-server/roadrunner:2.X.X
FROM ghcr.io/roadrunner-server/roadrunner:2.X.X AS roadrunner
FROM php:8.1-cli
COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr
You can also install RoadRunner automatically using command shipped with the composer package, run:
$ composer require spiral/roadrunner:v2.0 nyholm/psr7
$ ./vendor/bin/rr get-binary
Create a PHP worker using the following guide.
use Spiral\RoadRunner;
use Nyholm\Psr7;
include "vendor/autoload.php";
$worker = RoadRunner\Worker::create();
$psrFactory = new Psr7\Factory\Psr17Factory();
$psr7 = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);
while (true) {
try {
$request = $psr7->waitRequest();
if (!($request instanceof \Psr\Http\Message\ServerRequestInterface)) {
// Termination request received
break;
}
} catch (\Throwable) {
$psr7->respond(new Psr7\Response(400)); // Bad Request
continue;
}
try {
// Application code logic
$psr7->respond(new Psr7\Response(200, [], 'Hello RoadRunner!'));
} catch (\Throwable) {
$psr7->respond(new Psr7\Response(500, [], 'Something Went Wrong!'));
}
}
To write a configuration file explaining how RoadRunner should run your application:
server:
command: "php psr-worker.php"
http:
address: 0.0.0.0:8080
pool:
num_workers: 4
See full configuration example here.
RoadRunner application can be started by calling a simple command from the root of your PHP application:
$ rr serve
You can also start RoadRunner using configuration from custom location:
$ rr serve -c ./app/.rr.yaml
To reload all RoadRunner services:
$ rr reset
To reload silently:
$ rr reset --silent
To reset only particular plugins:
$ rr reset http
To run golang pprof server (debug mode):
$ rr serve -d -c .rr.yaml
To view the status of all active workers in an interactive mode:
$ rr workers -i -c .rr.yaml
RR support .env files. To read environment variables from the .env file, use the --dotenv CLI command:
$ rr serve --dotenv .env -c .rr.yaml
See more about console commands here.
Explore new ways to speed up your projects