Revision: Fri, 31 May 2024 16:10:57 GMT

Temporal — Getting started

Temporal is an open-source workflow engine that manage and execute reliable, durable and fault-tolerant workflows in a distributed manner. But the only way to use it in PHP is with RoadRunner. It makes it super easy to integrate your PHP app with Temporal, so you can start using it right away.

One cool thing about Temporal is that you can write your workflows and activities in any supported language. So for example, you could have a workflow written in PHP, but handle some of the activities with code written in Go or vice versa. This can be really helpful if you have a team with different language preferences, or if you want to take advantage of the strengths of different languages for different tasks.

Use Temporal when you have to manage complex data flows or ensure reliable transaction processing across multiple business domains. it provides timers, retry mechanisms and much more.


To use Temporal in your PHP project, you need to install the spiral/temporal-bridge package.

Here's how:

composer require spiral/temporal-bridge

After the package is installed, you will need to activate the component using the bootloader:

public function defineBootloaders(): array
    return [
        // ...
        // ...

Read more about bootloaders in the Framework — Bootloaders section.

Setting Up a Temporal Server

To start using Temporal quickly, use a development server.

First, install the Temporal CLI - follow the instructions on the Temporal website.

After the CLI is installed, you can start the Temporal server by running the following command:

temporal server start-dev

There are other ways to start a Temporal server. For example, you can use Docker. You can find docker-compose files in the Temporal repository.


PHP application

All you need is to specify the address of your Temporal server in the .env file:


If you want to precisely configure your application, you can create the temporal.php configuration file. There you can specify options such as a task queue, and individual worker configurations.

Here is an example configuration file:

use Temporal\Worker\WorkerFactoryInterface;
use Temporal\Worker\WorkerOptions;

return [
    'address' => env('TEMPORAL_ADDRESS', ''),
    'defaultWorker' => WorkerFactoryInterface::DEFAULT_TASK_QUEUE,
    'workers' => [
        'workerName' => WorkerOptions::new()


In your RoadRunner configuration file .rr.yaml, add a section temporal. This lets you set the server address and the number of workers. For example:


  address: localhost:7233
    num_workers: 10

For more details on configuring Temporal with RoadRunner, read the RoadRunner documentation.

That's it! Happy workflow building!