Skip to main content

Signals in PHP

use Temporal\Workflow;

class YourWorkflow
private bool $value;

public function run()
yield Workflow::await(fn()=> $this->value);
return 'OK';

public function setValue(bool $value)
$this->value = $value;

In the example above the workflow updates the protected value. Main workflow coroutine waits for such value to change using Workflow::await function.

To send signal to workflow use WorkflowClient->newWorkflowStub or WorkflowClient->newUntypedWorkflowStub:

$workflow = $workflowClient->newWorkflowStub(YourWorkflow::class);

$run = $workflowClient->start($workflow);

// do something


assert($run->getValue() === true);

Use WorkflowClient->newRunningWorkflowStub or WorkflowClient->newUntypedRunningWorkflowStub with workflow id to send signals to already running workflows.

$workflow = $workflowClient->newRunningWorkflowStub(YourWorkflow::class, 'workflowID');


You may not know if a Workflow is running and can accept a signal. The WorkflowClient->startWithSignal API allows you to send a signal to the current Workflow instance if one exists or to create a new run and then send the signal.

$workflow = $workflowClient->newWorkflowStub(YourWorkflow::class);

$run = $workflowClient->startWithSignal(
[true], // signal arguments
[] // start arguments