Skip to content
roadrunner-phpPublic

About

Base PHP worker for RoadRunner server.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

22 stars

Watchers

5 watching

Forks

Repository files navigation

RoadRunner

The common PHP worker for the RoadRunner application server

Documentation Sponsor

Psalm Level Type Coverage Mutation testing badge


This package contains the common codebase for all RoadRunner PHP workers: it receives payloads from the server over Goridge, sends responses back and gives access to the worker environment and the worker pool. Check roadrunner-server/roadrunner for the application server itself and roadrunner-php/http for a PSR-7 compatible HTTP worker.

Get Started

Installation

composer require spiral/roadrunner-worker

PHP Latest Version on Packagist License Total Downloads

The RoadRunner binary can be downloaded with the RoadRunner CLI:

composer require spiral/roadrunner-cli --dev
vendor/bin/rr get

Configuration

Point the RoadRunner server to your worker script in .rr.yaml:

version: '3'

server:
  command: "php worker.php"

See the documentation for the full list of options.

Writing a Worker

A minimal worker that receives payloads and responds to them:

<?php

require __DIR__ . '/vendor/autoload.php';

use Spiral\RoadRunner\Payload;
use Spiral\RoadRunner\Worker;

// Create a new Worker from the global environment
$worker = Worker::create();

while ($payload = $worker->waitPayload()) {
    // Received payload
    var_dump($payload->body);

    // Respond
    $worker->respond(new Payload('DONE'));
}

Testing

composer test
try Spiral Framework

About

Base PHP worker for RoadRunner server.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

22 stars

Watchers

5 watching

Forks

Releases

Sponsor this project

Contributors

Languages