The RoadRunner application server will launch multiple Temporal PHP Worker processes based on provided
Each Worker might connect to one or multiple Task Queues. Worker poll Temporal service for tasks, performs those tasks, and communicates task execution results back to the Temporal service.
Worker code are developed, deployed, and operated by Temporal customers.
To create a worker use
// 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.
// In case an activity class requires some external dependencies provide a callback - factory
// that creates or builds a new activity instance. The factory should be a callable which accepts
// an instance of ReflectionClass with an activity class which should be created.
$worker->registerActivity(App\DemoActivity::class, fn(ReflectionClass $class) => $container->create($class->getName()));
// start primary loop
You can configure task queue name using first argument of
$worker = $factory->newWorker('my-task-queue');
As mentioned above you can create as many Task Queue connections inside a single Worker Process as you need.
To configure additional WorkerOptions use
$worker = $factory->newWorker(
Make sure to point the Worker file in application server configuration:
command: "php worker.php"
You can serve HTTP endpoints using the same server setup.