PHP Classes


Recommend this page to a friend!
  Classes of Wolfy-J   roadrunner   Download  
Role: Example script
Content type: text/markdown
Description: Example script
Class: roadrunner
Run multiple tasks of PHP in parallel using Golang
Author: By
Last change:
Date: 5 years ago
Size: 2,634 bytes


Class file image Download


Latest Stable Version GoDoc Build Status Go Report Card Scrutinizer Code Quality Codecov

High-performance PHP load balancer and process manager library for Golang.

Library allows you to embed PHP code into Golang applications as managed pool of stateless workers.


  • no external services, drop-in (based on Goridge)
  • load balancer, process manager and task pipeline
  • frontend agnostic (queue, REST, PSR-7, async php, etc)
  • works over TPC, unix sockets and standard pipes
  • automatic worker replacement and safe PHP process destruction
  • worker lifecycle management (create/allocate/destroy timeouts)
  • payload context and body
  • control over max jobs per worker
  • protocol, worker and job level error management (including PHP errors)
  • very fast (~250k calls per second on Ryzen 1700X over 16 threads)
  • works on Windows


$ go get
$ composer require spiral/roadrunner


p, err := rr.NewPool(
    func() *exec.Cmd { return exec.Command("php", "worker.php", "pipes") },
        NumWorkers:      uint64(runtime.NumCPU()),
        AllocateTimeout: time.Second,              
        DestroyTimeout:  time.Second,               
defer p.Destroy()

rsp, err := p.Exec(&Payload{Body: []byte("hello")})
 * @var Goridge\RelayInterface $relay

use Spiral\Goridge;
use Spiral\RoadRunner;

$rr = new RoadRunner\Worker($relay);

while ($body = $rr->receive($context)) {
    try {
        $rr->send((string)$body, (string)$context);
    } catch (\Throwable $e) {

> Check how to init relay here. More examples can be found in tests.


The MIT License (MIT). Please see LICENSE for more information.