Temporal Worker

Unlike HTTP, Temporal use different way to configure a worker. Make sure to require PHP SDK:

$ composer require temporal/sdk

The worker file will look as following:



use Temporal\WorkerFactory;

ini_set('display_errors', 'stderr');
include "vendor/autoload.php";

// factory initiates and runs task queue specific activity and workflow workers
$factory = WorkerFactory::create();

// Worker that listens on a task queue and hosts both workflow and activity implementations.
$worker = $factory->newWorker(

// Workflows are stateful. So you need a type to create instances.

// Activities are stateless and thread safe. So a shared instance is used.
$worker->registerActivityImplementations(new MyActivity());

// start primary loop

Read more about temporal configuration and usage at official website.

Multi-worker Environment

To serve both HTTP and Temporal from the same worker use getMode() option of Environment:

use Spiral\RoadRunner;

$rrEnv = RoadRunner\Environment::fromGlobals();

if ($rrEnv->getMode() === RoadRunner\Environment\Mode::MODE_TEMPORAL) {
    // start temporal worker

if ($rrEnv->getMode() === RoadRunner\Environment\Mode::MODE_HTTP) {
    // start http worker

Or you may override server's command via:

  address: "localhost:7233"
    num_workers: 10
    command: "php temporal.php"
Edit this page