Convert Figma logo to code with AI

roadrunner-server logoroadrunner

🤯 High-performance PHP application server, process manager written in Go and powered with plugins

7,836
407
7,836
61

Top Related Projects

🤯 High-performance PHP application server, process manager written in Go and powered with plugins

6,555

PPM is a process manager, supercharger and load balancer for modern PHP applications.

An advanced async HTTP server library for PHP, perfect for real-time apps and APIs with high concurrency demands.

Quick Overview

RoadRunner is a high-performance PHP application server, load balancer, and process manager written in Go. It's designed to boost the performance of PHP applications by handling concurrent requests more efficiently than traditional PHP-FPM setups.

Pros

  • Significantly improved performance and reduced resource usage compared to traditional PHP setups
  • Built-in load balancing and process management capabilities
  • Support for various PHP frameworks and applications
  • Extensible plugin system for additional functionality

Cons

  • Steeper learning curve compared to traditional PHP setups
  • May require changes to existing application code for optimal performance
  • Limited compatibility with some PHP extensions and libraries
  • Potential complexity in debugging due to the Go-based server layer

Code Examples

  1. Basic RoadRunner configuration (.rr.yaml):
http:
  address: "0.0.0.0:8080"
  workers:
    command: "php worker.php"
    pool:
      numWorkers: 4

This configuration sets up RoadRunner to listen on port 8080 and use 4 PHP worker processes.

  1. PHP worker script (worker.php):
<?php
use Spiral\RoadRunner;
use Nyholm\Psr7;

$worker = RoadRunner\Worker::create();
$psrFactory = new Psr7\Factory\Psr17Factory();

while ($req = $worker->waitRequest()) {
    try {
        $resp = new Psr7\Response();
        $resp->getBody()->write('Hello World!');
        
        $worker->respond($resp);
    } catch (\Throwable $e) {
        $worker->error((string)$e);
    }
}

This PHP script sets up a worker that responds to incoming requests with "Hello World!".

  1. Using RoadRunner with Symfony:
<?php
use App\Kernel;
use Spiral\RoadRunner\Worker;
use Spiral\RoadRunner\Http\PSR7Worker;
use Nyholm\Psr7;

$worker = Worker::create();
$psrFactory = new Psr7\Factory\Psr17Factory();
$psr7 = new PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);

while ($request = $psr7->waitRequest()) {
    try {
        $response = $kernel->handle($request);
        $psr7->respond($response);
    } catch (\Throwable $e) {
        $psr7->getWorker()->error((string)$e);
    }
}

This example shows how to integrate RoadRunner with a Symfony application.

Getting Started

  1. Install RoadRunner:

    curl -s https://packagecloud.io/install/repositories/roadrunner/roadrunner/script.deb.sh | sudo bash
    sudo apt-get install roadrunner
    
  2. Create a .rr.yaml configuration file (see example above).

  3. Create a PHP worker script (see example above).

  4. Run RoadRunner:

    rr serve
    
  5. Your high-performance PHP application is now running with RoadRunner!

Competitor Comparisons

🤯 High-performance PHP application server, process manager written in Go and powered with plugins

Pros of RoadRunner

  • Highly performant application server for PHP applications
  • Supports multiple PHP versions and frameworks
  • Provides built-in load balancing and worker management

Cons of RoadRunner

  • Steeper learning curve compared to traditional PHP setups
  • Requires additional configuration and setup
  • May not be suitable for all PHP applications, especially those heavily reliant on global state

Code Comparison

RoadRunner configuration example:

http:
  address: 0.0.0.0:8080
  workers:
    command: "php worker.php"
    pool:
      numWorkers: 4

Additional Notes

Both repositories (roadrunner-server/roadrunner and roadrunner-server/roadrunner>) appear to be the same project. The comparison provided is based on the features and characteristics of RoadRunner itself, as there is no distinct difference between the two repositories.

RoadRunner is designed to improve PHP application performance by managing workers and handling requests more efficiently. It's particularly useful for high-load applications and microservices. However, it may require developers to adapt their coding practices and application architecture to fully leverage its benefits.

6,555

PPM is a process manager, supercharger and load balancer for modern PHP applications.

Pros of PHP-PM

  • Designed specifically for PHP applications, offering deep integration with PHP ecosystems
  • Supports multiple frameworks out of the box (Symfony, Laravel, Zend)
  • Easier setup for developers already familiar with PHP environments

Cons of PHP-PM

  • Less active development and community support compared to RoadRunner
  • Limited to PHP applications, while RoadRunner supports multiple languages
  • May have lower performance in certain scenarios due to its pure PHP implementation

Code Comparison

PHP-PM:

$app = new \PHPPM\Bridges\HttpKernel($kernel);
$socketPath = '/tmp/php-pm.sock';
$app->run($socketPath, 8, 'unix');

RoadRunner:

rr serve -c .rr.yaml
http:
  address: "0.0.0.0:8080"
  workers:
    command: "php worker.php"
    pool:
      numWorkers: 4

RoadRunner uses a more language-agnostic approach with configuration files, while PHP-PM is more PHP-centric in its setup. RoadRunner's configuration allows for easier scaling and customization of worker processes.

An advanced async HTTP server library for PHP, perfect for real-time apps and APIs with high concurrency demands.

Pros of http-server

  • Built on the amphp ecosystem, providing seamless integration with other amphp libraries
  • Designed for asynchronous PHP applications, offering non-blocking I/O operations
  • Lightweight and easy to set up for simple HTTP server needs

Cons of http-server

  • Limited to PHP applications, whereas RoadRunner supports multiple languages
  • Lacks the advanced features and performance optimizations of RoadRunner
  • Smaller community and ecosystem compared to RoadRunner

Code Comparison

http-server:

$server = new Server($socket, new RequestHandler());
yield $server->start();

RoadRunner:

$worker = Worker::create();
$psr7 = new PSR7Worker($worker);

while ($req = $psr7->waitRequest()) {
    $psr7->respond(new Response(200, [], 'Hello World!'));
}

RoadRunner uses a more traditional worker-based approach, while http-server leverages amphp's asynchronous programming model. RoadRunner's code structure is more familiar to PHP developers accustomed to long-running processes, whereas http-server's approach aligns with event-driven programming paradigms.

Both projects serve as HTTP servers for PHP applications, but RoadRunner offers a more comprehensive solution with support for multiple languages and advanced features like load balancing and process management. http-server, on the other hand, provides a simpler, lightweight option for developers working within the amphp ecosystem and focusing on asynchronous PHP applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

All releases

RoadRunner is an open-source (MIT licensed) high-performance PHP application server, process manager written in Go and powered with plugins ❤️. It supports running as a service with the ability to extend its functionality on a per-project basis with plugins.

Features

RoadRunner features a range of plugins, including HTTP(S)/2/3 and fCGI servers that are compatible with PSR-7/PSR-17 standards. This is just one of its many capabilities. It serves as an effective alternative to the traditional Nginx+FPM setup, providing improved performance and more flexibility. Its extensive plugin options go far beyond just HTTP(S)/2/3 and fCGI servers, offering a broad range of functionalities:

  • Queue drivers: RabbitMQ, Kafka, SQS, Beanstalk, NATS, In-Memory.
  • KV drivers: Redis, Memcached, BoltDB, In-Memory.
  • OpenTelemetry protocol support (gRPC, http, jaeger).
  • Workflow engine via Temporal.
  • gRPC server. For increased speed, the protobuf extension can be used.
  • HTTP(S)/2/3 and fCGI servers features automatic TLS management, 103 Early Hints support and middleware like: Static, Headers, gzip, prometheus (metrics), send (x-sendfile), OTEL, proxy_ip_parser, etc.
  • Embedded distribute lock plugin which manages access to shared resources.
  • Metrics server (you might easily expose your own).
  • WebSockets and Broadcast via Centrifugo server.
  • Systemd-like services manager with auto-restarts, execution time limiter, etc.
  • Production-ready.
  • And more 😉

Join our discord server: Link

Official Website | Documentation | Forum | Release schedule

Installation

The easiest way to get the latest RoadRunner version is to use one of the pre-built release binaries, which are available for OSX, Linux, FreeBSD, and Windows. Instructions for using these binaries are on the GitHub releases page.

Docker:

To get the roadrunner binary file you can use our docker image: ghcr.io/roadrunner-server/roadrunner:2024.X.X (more information about image and tags can be found here).

FROM ghcr.io/roadrunner-server/roadrunner:2024.X.X AS roadrunner
FROM php:8.3-cli

COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr

# USE THE RR

Configuration located in the .rr.yaml file (full sample):

Installation via Composer

You can also install RoadRunner automatically using the command shipped with the composer package, run:

composer require spiral/roadrunner-cli
./vendor/bin/rr get-binary

Server binary will be available at the root of your project.

Note

PHP's extensions php-curl and php-zip are required to download RoadRunner automatically. PHP's extensions php-sockets need to be installed to run roadrunner. Check with php --modules your installed extensions.

Installation option for the Debian-derivatives (Ubuntu, Mint, MX, etc)

wget https://github.com/roadrunner-server/roadrunner/releases/download/v2024.X.X/roadrunner-2024.X.X-linux-amd64.deb
sudo dpkg -i roadrunner-2024.X.X-linux-amd64.deb

Download the latest release via curl:

curl --proto '=https' --tlsv1.2 -sSf  https://raw.githubusercontent.com/roadrunner-server/roadrunner/master/download-latest.sh | sh

MacOS using Homebrew:

brew install roadrunner

Windows using Chocolatey:

choco install roadrunner

Configuration can be located in .rr.yaml file (full sample):

version: '3'

rpc:
  listen: tcp://127.0.0.1:6001

server:
  command: "php worker.php"

http:
  address: "0.0.0.0:8080"

logs:
  level: error

Read more in Documentation.

Example Worker:

<?php

use Spiral\RoadRunner;
use Nyholm\Psr7;

include "vendor/autoload.php";

$worker = RoadRunner\Worker::create();
$psrFactory = new Psr7\Factory\Psr17Factory();

$worker = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);

while ($req = $worker->waitRequest()) {
    try {
        $rsp = new Psr7\Response();
        $rsp->getBody()->write('Hello world!');

        $worker->respond($rsp);
    } catch (\Throwable $e) {
        $worker->getWorker()->error((string)$e);
    }
}

[!IMPORTANT] If you see the EOF error, check that you have installed the PHP packages from this step. If this does not help, try to execute the command php worker.php directly and check the output.


Available Plugins: link

Run:

To run application server:

$ ./rr serve -c .rr.yaml

License:

The MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.

Contributors

Thanks to all the people who already contributed!