PHP code example of spiral / roadrunner-worker

1. Go to this page and download the library: Download spiral/roadrunner-worker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spiral / roadrunner-worker example snippets




piral\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'));
}
yaml
version: '3'

server:
  command: "php worker.php"