Modernizing PHP Applications with Golang

RoadRunner is a high-performance PHP application server, load-balancer, and process manager written in Golang.

Production Ready

Production Ready

RoadRunner can be installed and used in production right away for even the biggest applications under constant load.

High Performance

High Performance

RoadRunner utilizes goroutines and the multi-threading capabilities of Golang to bring maximum performance to PHP applications.

Works Everywhere

Works Everywhere

You can download or compile RoadRunner binaries that work on Mac OS, Windows, Linux, FreeBSD, and ARM.

Golang Extensions

Golang Extensions

RoadRunner provides a flexible framework that allows you to integrate any Golang library with your application using Goridge RPC protocol.

Rich Error Management

Rich Error Management

RoadRunner supports effective application, server and protocol error handling. You can also connect custom handlers or reporters like Sentry, Prometheus, etc.

HTTP/2, gRPC, PSR-7

HTTP/2, gRPC, PSR-7

RoadRunner offers a versatile foundation library that allows for running your application under HTTP/2, gRPC, Queue, etc.

How to install RoadRunner

A simple guide to using RoadRunner

Docker

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

RoadRunner CLI

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.

Companies using RoadRunner

Contact us

Please, enter your name
Please, enter valid email
Please, enter your message

Meet other Spiral Scout products

Explore new ways to speed up your projects

Spiral Framework

High-Performance PHP/Go Framework
Born out of real-world software development projects, Spiral Framework is a modern PHP framework designed to power faster, cleaner, superior software development.

Cycle ORM

DataMapper ORM and Data Modelling engine
The ORM provides flexible configuration options to model datasets, a powerful query builder, and supports dynamic mapping schemas.