The common PHP worker for the RoadRunner application server
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.
composer require spiral/roadrunner-workerThe RoadRunner binary can be downloaded with the RoadRunner CLI:
composer require spiral/roadrunner-cli --dev
vendor/bin/rr getPoint 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.
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'));
}composer test