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.
// 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()));
// If you want to clean up some resources after activity is done, you may register
// a finalizer. This callback is called after each activity invocation.
$worker->registerActivityFinalizer(fn () => $kernel->showtdown());
// start primary loop
You can configure task queue name using first argument of
$worker = $factory->newWorker('your-task-queue');
As mentioned above you can create as many task queue connections inside a single worker as you need.
To configure additional worker options 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.