From d7df9145da592e74732fdfc6e7fe6dc2a81343b6 Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:19:26 +0530 Subject: [PATCH 01/13] feat(workflow): expose terminate and get workflow APIs --- src/lib/Client/DaprClient.php | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/lib/Client/DaprClient.php b/src/lib/Client/DaprClient.php index f0834dd..ea44c4e 100644 --- a/src/lib/Client/DaprClient.php +++ b/src/lib/Client/DaprClient.php @@ -458,6 +458,51 @@ abstract public function isDaprHealthy(): bool; */ abstract public function getMetadata(): MetadataResponse|null; + /** + * Terminate a workflow instance. + * + * @param string $workflowComponent The workflow component name, usually dapr. + * @param string $instanceId The workflow instance ID. + * @param string|null $reason Optional termination reason. + * @param string|null $appId Optional ID of the app hosting the workflow. + */ + abstract public function terminateWorkflow( + string $workflowComponent, + string $instanceId, + ?string $reason = null, + ?string $appId = null + ): void; + + /** + * @return PromiseInterface + */ + abstract public function terminateWorkflowAsync( + string $workflowComponent, + string $instanceId, + ?string $reason = null, + ?string $appId = null + ): PromiseInterface; + + /** + * Retrieve workflow instance metadata, including the termination reason when present. + * + * @return array + */ + abstract public function getWorkflow( + string $workflowComponent, + string $instanceId, + ?string $appId = null + ): array; + + /** + * @return PromiseInterface> + */ + abstract public function getWorkflowAsync( + string $workflowComponent, + string $instanceId, + ?string $appId = null + ): PromiseInterface; + /** * Shutdown the Daprd sidecar * From 19df7ff1e91275086e09f6db8ef728cfe95bb59c Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:19:43 +0530 Subject: [PATCH 02/13] feat(workflow): wire HTTP workflow client trait --- src/lib/Client/DaprHttpClient.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/Client/DaprHttpClient.php b/src/lib/Client/DaprHttpClient.php index c8e2aa5..1c83c8b 100644 --- a/src/lib/Client/DaprHttpClient.php +++ b/src/lib/Client/DaprHttpClient.php @@ -18,6 +18,7 @@ class DaprHttpClient extends DaprClient use HttpSecretsTrait; use HttpInvokeTrait; use HttpPubSubTrait; + use HttpWorkflowTrait; use HttpBindingTrait; use HttpActorTrait; use HttpTokenTrait; From 19e19ac62d3c6e8523573821f77881e362a741be Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:19:46 +0530 Subject: [PATCH 03/13] docs(workflow): document PHP workflow termination reasons --- readme.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/readme.md b/readme.md index be42dec..bc1ffbc 100644 --- a/readme.md +++ b/readme.md @@ -273,6 +273,33 @@ $client->invokeActorMethod( More detail here: https://docs.dapr.io/developing-applications/building-blocks/actors/actors-overview/ +# Workflows + +The client can terminate a workflow instance and retrieve its metadata. A runtime with workflow termination-reason support is required to persist and return the reason. + +```php +$client = \\Dapr\\Client\\DaprClient::clientBuilder()->build(); + +// The reason is optional and is stored separately from the workflow output. +$client->terminateWorkflow( + workflowComponent: 'dapr', + instanceId: 'order-123', + reason: 'cancelled by operator' +); + +// Read the reason from workflow metadata later. +$workflow = $client->getWorkflow( + workflowComponent: 'dapr', + instanceId: 'order-123' +); + +$terminationReason = $workflow['properties']['dapr.workflow.termination_reason'] ?? null; +``` + +Both operations have asynchronous variants: `terminateWorkflowAsync()` and `getWorkflowAsync()`. Pass `appId` to target a workflow hosted by another application in the same namespace, subject to that application's workflow access policy. + +The workflow HTTP API is deprecated by Dapr in favor of SDK workflow clients using gRPC. This PHP client currently uses the HTTP API. + # Pub/Sub Delivering events around your application is an important aspect of any application. This is supported by Dapr, and From abf71d144881907d2d5028275c8efebf2d74ada4 Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:19:48 +0530 Subject: [PATCH 04/13] feat(workflow): add HTTP workflow management methods --- src/lib/Client/HttpWorkflowTrait.php | 114 +++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/lib/Client/HttpWorkflowTrait.php diff --git a/src/lib/Client/HttpWorkflowTrait.php b/src/lib/Client/HttpWorkflowTrait.php new file mode 100644 index 0000000..2a3452e --- /dev/null +++ b/src/lib/Client/HttpWorkflowTrait.php @@ -0,0 +1,114 @@ +terminateWorkflowAsync($workflowComponent, $instanceId, $reason, $appId)->wait(true); + } + + /** + * Terminates a workflow instance asynchronously. + * + * A null reason is omitted from the request. An explicitly empty reason is + * sent as reason=, preserving protobuf field presence semantics. + * + * @return PromiseInterface + */ + public function terminateWorkflowAsync( + string $workflowComponent, + string $instanceId, + ?string $reason = null, + ?string $appId = null + ): PromiseInterface { + $query = []; + if ($reason !== null) { + $query['reason'] = $reason; + } + if ($appId !== null) { + $query['appID'] = $appId; + } + + $options = $query === [] ? [] : ['query' => $query]; + $uri = sprintf( + '/v1.0/workflows/%s/%s/terminate', + rawurlencode($workflowComponent), + rawurlencode($instanceId) + ); + + return $this->handlePromise( + $this->httpClient->postAsync($uri, $options), + static fn(ResponseInterface $response): null => null + ); + } + + /** + * Gets workflow instance metadata. + * + * The termination reason, when present, is exposed at + * properties['dapr.workflow.termination_reason']. + * + * @return array + * @throws \Dapr\exceptions\DaprException + */ + public function getWorkflow( + string $workflowComponent, + string $instanceId, + ?string $appId = null + ): array { + return $this->getWorkflowAsync($workflowComponent, $instanceId, $appId)->wait(); + } + + /** + * Gets workflow instance metadata asynchronously. + * + * @return PromiseInterface> + */ + public function getWorkflowAsync( + string $workflowComponent, + string $instanceId, + ?string $appId = null + ): PromiseInterface { + $options = $appId === null ? [] : ['query' => ['appID' => $appId]]; + $uri = sprintf( + '/v1.0/workflows/%s/%s', + rawurlencode($workflowComponent), + rawurlencode($instanceId) + ); + + return $this->handlePromise( + $this->httpClient->getAsync($uri, $options), + fn(ResponseInterface $response): array => $this->deserializer->from_json( + 'array', + $response->getBody()->getContents() + ) + ); + } +} From 2b2f1a1b62908fa2c47c12056e513b36ac02bc28 Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:19:50 +0530 Subject: [PATCH 05/13] test(workflow): cover termination reason API --- tests/WorkflowTest.php | 120 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 tests/WorkflowTest.php diff --git a/tests/WorkflowTest.php b/tests/WorkflowTest.php new file mode 100644 index 0000000..f410c57 --- /dev/null +++ b/tests/WorkflowTest.php @@ -0,0 +1,120 @@ +get_http_client_stack([new Response(202)]); + $client = $this->get_new_client_with_http($stack->client); + + $client->terminateWorkflow( + workflowComponent: 'dapr', + instanceId: 'order-123', + reason: 'cancelled by operator', + appId: 'orders' + ); + + $request = $stack->history[0]['request']; + $this->assertRequestMethod('POST', $request); + $this->assertRequestUri('/v1.0/workflows/dapr/order-123/terminate', $request); + $this->assertRequestBody('', $request); + + parse_str($request->getUri()->getQuery(), $query); + $this->assertSame( + ['reason' => 'cancelled by operator', 'appID' => 'orders'], + $query + ); + } + + public function testTerminateWorkflowOmitsAnUnspecifiedReason(): void + { + $stack = $this->get_http_client_stack([new Response(202)]); + $client = $this->get_new_client_with_http($stack->client); + + $client->terminateWorkflow('dapr', 'order-123'); + + $request = $stack->history[0]['request']; + $this->assertRequestMethod('POST', $request); + $this->assertRequestUri('/v1.0/workflows/dapr/order-123/terminate', $request); + $this->assertSame('', $request->getUri()->getQuery()); + } + + public function testTerminateWorkflowPreservesAnExplicitlyEmptyReason(): void + { + $stack = $this->get_http_client_stack([new Response(202)]); + $client = $this->get_new_client_with_http($stack->client); + + $client->terminateWorkflow('dapr', 'order-123', ''); + + $request = $stack->history[0]['request']; + parse_str($request->getUri()->getQuery(), $query); + + $this->assertArrayHasKey('reason', $query); + $this->assertSame('', $query['reason']); + } + + public function testTerminateWorkflowAsyncResolvesAfterTheRequestSucceeds(): void + { + $stack = $this->get_http_client_stack([new Response(202)]); + $client = $this->get_new_client_with_http($stack->client); + + $result = $client->terminateWorkflowAsync('dapr', 'order-123', 'operator request')->wait(); + + $this->assertNull($result); + $this->assertRequestMethod('POST', $stack->history[0]['request']); + } + + public function testGetWorkflowReturnsMetadataWithTerminationReason(): void + { + $body = json_encode([ + 'createdAt' => '2026-11-16T00:00:00Z', + 'instanceID' => 'order-123', + 'lastUpdatedAt' => '2026-11-16T00:01:00Z', + 'runtimeStatus' => 'TERMINATED', + 'properties' => [ + 'dapr.workflow.termination_reason' => 'cancelled by operator', + ], + ], JSON_THROW_ON_ERROR); + + $stack = $this->get_http_client_stack([new Response(200, body: $body)]); + $client = $this->get_new_client_with_http($stack->client); + + $workflow = $client->getWorkflow('dapr', 'order-123', 'orders'); + + $this->assertSame('TERMINATED', $workflow['runtimeStatus']); + $this->assertSame( + 'cancelled by operator', + $workflow['properties']['dapr.workflow.termination_reason'] + ); + + $request = $stack->history[0]['request']; + $this->assertRequestMethod('GET', $request); + $this->assertRequestUri('/v1.0/workflows/dapr/order-123', $request); + parse_str($request->getUri()->getQuery(), $query); + $this->assertSame(['appID' => 'orders'], $query); + } + + public function testGetWorkflowAsyncReturnsDecodedMetadata(): void + { + $body = json_encode([ + 'instanceID' => 'order-123', + 'runtimeStatus' => 'TERMINATED', + 'properties' => [ + 'dapr.workflow.termination_reason' => 'operator request', + ], + ], JSON_THROW_ON_ERROR); + + $stack = $this->get_http_client_stack([new Response(200, body: $body)]); + $client = $this->get_new_client_with_http($stack->client); + + $workflow = $client->getWorkflowAsync('dapr', 'order-123')->wait(); + + $this->assertSame('operator request', $workflow['properties']['dapr.workflow.termination_reason']); + $this->assertRequestMethod('GET', $stack->history[0]['request']); + $this->assertSame('', $stack->history[0]['request']->getUri()->getQuery()); + } +} From f8090ee20d8ea797f9d6f22af8e2a56295e6315b Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:20:49 +0530 Subject: [PATCH 06/13] docs(workflow): fix PHP client example namespace --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index bc1ffbc..7514c46 100644 --- a/readme.md +++ b/readme.md @@ -278,7 +278,7 @@ More detail here: https://docs.dapr.io/developing-applications/building-blocks/a The client can terminate a workflow instance and retrieve its metadata. A runtime with workflow termination-reason support is required to persist and return the reason. ```php -$client = \\Dapr\\Client\\DaprClient::clientBuilder()->build(); +$client = \Dapr\Client\DaprClient::clientBuilder()->build(); // The reason is optional and is stored separately from the workflow output. $client->terminateWorkflow( From 30fcbb3f66e97e1e400d8e71e86dfa50983c18b6 Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:20:51 +0530 Subject: [PATCH 07/13] docs(workflow): add PHP workflow termination guide --- .../en/php-sdk-docs/php-workflows/_index.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 daprdocs/content/en/php-sdk-docs/php-workflows/_index.md diff --git a/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md b/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md new file mode 100644 index 0000000..90592f1 --- /dev/null +++ b/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md @@ -0,0 +1,56 @@ +--- +type: docs +title: "Workflows with PHP" +linkTitle: "Workflows" +weight: 1000 +description: Manage Dapr workflow instances from PHP +no_list: true +--- + +The PHP client exposes the Dapr workflow termination and metadata HTTP APIs. Use these methods to stop a running workflow and inspect the reason after it has been terminated. + +## Terminate a workflow + +Pass a reason to record why an instance was terminated. The reason is optional and is stored separately from the workflow output. + +```php +$client->terminateWorkflow( + workflowComponent: 'dapr', + instanceId: 'order-123', + reason: 'cancelled by operator' +); +``` + +To terminate a workflow owned by another application in the same namespace, pass its application ID: + +```php +$client->terminateWorkflow( + workflowComponent: 'dapr', + instanceId: 'order-123', + reason: 'cancelled by operator', + appId: 'orders' +); +``` + +A null reason is omitted. Passing an empty string explicitly sends an empty reason. + +## Read the termination reason + +Retrieve the workflow metadata and read the reason from the `properties` map: + +```php +$workflow = $client->getWorkflow( + workflowComponent: 'dapr', + instanceId: 'order-123' +); + +$terminationReason = $workflow['properties']['dapr.workflow.termination_reason'] ?? null; +``` + +The property is absent for workflows that have not been terminated with a reason, and when the connected runtime does not expose termination reasons. + +The asynchronous variants are `terminateWorkflowAsync()` and `getWorkflowAsync()`. + +## API compatibility + +The PHP SDK currently uses Dapr's HTTP workflow API at `/v1.0/workflows`. Dapr marks this HTTP API as deprecated in favor of workflow SDK clients that use gRPC. The PHP SDK does not currently provide a gRPC workflow client. From a4ced4fdb243001d4c1b5be39ae78bb8a083cc83 Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:22:27 +0530 Subject: [PATCH 08/13] docs(workflow): clarify runtime HTTP reason support dependency --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 7514c46..e957c6a 100644 --- a/readme.md +++ b/readme.md @@ -300,6 +300,8 @@ Both operations have asynchronous variants: `terminateWorkflowAsync()` and `getW The workflow HTTP API is deprecated by Dapr in favor of SDK workflow clients using gRPC. This PHP client currently uses the HTTP API. +**Runtime compatibility:** the termination-reason runtime change is still in draft. The current [Dapr runtime PR](https://github.com/dapr/dapr/pull/11140) adds the reason to the gRPC workflow request and metadata, but does not yet update the HTTP workflow handler to map the `reason` query parameter into that request. The PHP client sends the intended HTTP query parameter; the reason will only be persisted once that handler change is included in a runtime build. + # Pub/Sub Delivering events around your application is an important aspect of any application. This is supported by Dapr, and From 752fea3eb589abce148e12d15adec5f121d3caf4 Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Mon, 16 Nov 2026 03:22:29 +0530 Subject: [PATCH 09/13] docs(workflow): clarify runtime HTTP reason support dependency --- daprdocs/content/en/php-sdk-docs/php-workflows/_index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md b/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md index 90592f1..83e36c9 100644 --- a/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md +++ b/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md @@ -54,3 +54,5 @@ The asynchronous variants are `terminateWorkflowAsync()` and `getWorkflowAsync() ## API compatibility The PHP SDK currently uses Dapr's HTTP workflow API at `/v1.0/workflows`. Dapr marks this HTTP API as deprecated in favor of workflow SDK clients that use gRPC. The PHP SDK does not currently provide a gRPC workflow client. + +**Runtime compatibility:** the termination-reason runtime change is still in draft. The current [Dapr runtime PR](https://github.com/dapr/dapr/pull/11140) adds the reason to the gRPC workflow request and metadata, but does not yet update the HTTP workflow handler to map the `reason` query parameter into that request. The PHP client sends the intended HTTP query parameter; the reason will only be persisted once that handler change is included in a runtime build. From 976681a07eb62d57e031ef6a7e4db6bcad7ce52f Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:13:46 +0530 Subject: [PATCH 10/13] refactor(workflow): expose termination reason through custom status --- src/lib/Client/HttpWorkflowTrait.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/Client/HttpWorkflowTrait.php b/src/lib/Client/HttpWorkflowTrait.php index 2a3452e..5a7719a 100644 --- a/src/lib/Client/HttpWorkflowTrait.php +++ b/src/lib/Client/HttpWorkflowTrait.php @@ -20,8 +20,8 @@ trait HttpWorkflowTrait /** * Terminates a workflow instance. * - * The reason is optional and is persisted separately from the workflow - * output by runtimes that support workflow termination reasons. + * The reason is optional and is recorded as the termination input. The runtime + * exposes it through the workflow custom-status property. * * @throws \Dapr\exceptions\DaprException */ @@ -38,7 +38,7 @@ public function terminateWorkflow( * Terminates a workflow instance asynchronously. * * A null reason is omitted from the request. An explicitly empty reason is - * sent as reason=, preserving protobuf field presence semantics. + * sent as reason=, preserving the distinction between an omitted reason and an explicit empty reason. * * @return PromiseInterface */ @@ -73,7 +73,7 @@ public function terminateWorkflowAsync( * Gets workflow instance metadata. * * The termination reason, when present, is exposed at - * properties['dapr.workflow.termination_reason']. + * properties['dapr.workflow.custom_status']. * * @return array * @throws \Dapr\exceptions\DaprException From 8601129912547a74cd290314cd16917856a337d3 Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:13:49 +0530 Subject: [PATCH 11/13] test(workflow): read termination reason from custom status --- tests/WorkflowTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/WorkflowTest.php b/tests/WorkflowTest.php index f410c57..7725c83 100644 --- a/tests/WorkflowTest.php +++ b/tests/WorkflowTest.php @@ -76,7 +76,7 @@ public function testGetWorkflowReturnsMetadataWithTerminationReason(): void 'lastUpdatedAt' => '2026-11-16T00:01:00Z', 'runtimeStatus' => 'TERMINATED', 'properties' => [ - 'dapr.workflow.termination_reason' => 'cancelled by operator', + 'dapr.workflow.custom_status' => 'cancelled by operator', ], ], JSON_THROW_ON_ERROR); @@ -88,7 +88,7 @@ public function testGetWorkflowReturnsMetadataWithTerminationReason(): void $this->assertSame('TERMINATED', $workflow['runtimeStatus']); $this->assertSame( 'cancelled by operator', - $workflow['properties']['dapr.workflow.termination_reason'] + $workflow['properties']['dapr.workflow.custom_status'] ); $request = $stack->history[0]['request']; @@ -104,7 +104,7 @@ public function testGetWorkflowAsyncReturnsDecodedMetadata(): void 'instanceID' => 'order-123', 'runtimeStatus' => 'TERMINATED', 'properties' => [ - 'dapr.workflow.termination_reason' => 'operator request', + 'dapr.workflow.custom_status' => 'operator request', ], ], JSON_THROW_ON_ERROR); @@ -113,7 +113,7 @@ public function testGetWorkflowAsyncReturnsDecodedMetadata(): void $workflow = $client->getWorkflowAsync('dapr', 'order-123')->wait(); - $this->assertSame('operator request', $workflow['properties']['dapr.workflow.termination_reason']); + $this->assertSame('operator request', $workflow['properties']['dapr.workflow.custom_status']); $this->assertRequestMethod('GET', $stack->history[0]['request']); $this->assertSame('', $stack->history[0]['request']->getUri()->getQuery()); } From 1b5ec0d13ffcad6b024fa5ff769970da007fe87e Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:13:53 +0530 Subject: [PATCH 12/13] docs(workflow): document termination input and custom status --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index e957c6a..2cc1c93 100644 --- a/readme.md +++ b/readme.md @@ -275,12 +275,12 @@ More detail here: https://docs.dapr.io/developing-applications/building-blocks/a # Workflows -The client can terminate a workflow instance and retrieve its metadata. A runtime with workflow termination-reason support is required to persist and return the reason. +The client can terminate a workflow instance and retrieve its metadata. A runtime with workflow termination-reason support is required to persist the reason and expose it through `dapr.workflow.custom_status`. ```php $client = \Dapr\Client\DaprClient::clientBuilder()->build(); -// The reason is optional and is stored separately from the workflow output. +// The reason is optional and is stored as the workflow termination input, exposed through the existing custom-status property. $client->terminateWorkflow( workflowComponent: 'dapr', instanceId: 'order-123', @@ -293,14 +293,14 @@ $workflow = $client->getWorkflow( instanceId: 'order-123' ); -$terminationReason = $workflow['properties']['dapr.workflow.termination_reason'] ?? null; +$terminationReason = $workflow['properties']['dapr.workflow.custom_status'] ?? null; ``` Both operations have asynchronous variants: `terminateWorkflowAsync()` and `getWorkflowAsync()`. Pass `appId` to target a workflow hosted by another application in the same namespace, subject to that application's workflow access policy. The workflow HTTP API is deprecated by Dapr in favor of SDK workflow clients using gRPC. This PHP client currently uses the HTTP API. -**Runtime compatibility:** the termination-reason runtime change is still in draft. The current [Dapr runtime PR](https://github.com/dapr/dapr/pull/11140) adds the reason to the gRPC workflow request and metadata, but does not yet update the HTTP workflow handler to map the `reason` query parameter into that request. The PHP client sends the intended HTTP query parameter; the reason will only be persisted once that handler change is included in a runtime build. +**Runtime compatibility:** the termination-reason runtime change is still in draft. The Dapr runtime maps the optional `reason` query parameter to its workflow termination request and exposes a supplied reason through `dapr.workflow.custom_status`. # Pub/Sub From 80e0f9590c90c64a7eaeb41f0f3618efd72896af Mon Sep 17 00:00:00 2001 From: Sai Kiran Maggidi <107541780+ep0ll@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:13:57 +0530 Subject: [PATCH 13/13] docs(workflow): document termination input and custom status --- .../content/en/php-sdk-docs/php-workflows/_index.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md b/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md index 83e36c9..39db65d 100644 --- a/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md +++ b/daprdocs/content/en/php-sdk-docs/php-workflows/_index.md @@ -11,7 +11,7 @@ The PHP client exposes the Dapr workflow termination and metadata HTTP APIs. Use ## Terminate a workflow -Pass a reason to record why an instance was terminated. The reason is optional and is stored separately from the workflow output. +Pass a reason to record why an instance was terminated. The reason is optional and is stored as the workflow termination input, exposed through the existing custom-status property. ```php $client->terminateWorkflow( @@ -36,7 +36,7 @@ A null reason is omitted. Passing an empty string explicitly sends an empty reas ## Read the termination reason -Retrieve the workflow metadata and read the reason from the `properties` map: +Retrieve the workflow metadata and read the reason from the `properties` map under `dapr.workflow.custom_status`: ```php $workflow = $client->getWorkflow( @@ -44,10 +44,10 @@ $workflow = $client->getWorkflow( instanceId: 'order-123' ); -$terminationReason = $workflow['properties']['dapr.workflow.termination_reason'] ?? null; +$terminationReason = $workflow['properties']['dapr.workflow.custom_status'] ?? null; ``` -The property is absent for workflows that have not been terminated with a reason, and when the connected runtime does not expose termination reasons. +When no reason is supplied, the existing workflow custom status remains unchanged. The asynchronous variants are `terminateWorkflowAsync()` and `getWorkflowAsync()`. @@ -55,4 +55,4 @@ The asynchronous variants are `terminateWorkflowAsync()` and `getWorkflowAsync() The PHP SDK currently uses Dapr's HTTP workflow API at `/v1.0/workflows`. Dapr marks this HTTP API as deprecated in favor of workflow SDK clients that use gRPC. The PHP SDK does not currently provide a gRPC workflow client. -**Runtime compatibility:** the termination-reason runtime change is still in draft. The current [Dapr runtime PR](https://github.com/dapr/dapr/pull/11140) adds the reason to the gRPC workflow request and metadata, but does not yet update the HTTP workflow handler to map the `reason` query parameter into that request. The PHP client sends the intended HTTP query parameter; the reason will only be persisted once that handler change is included in a runtime build. +**Runtime compatibility:** the termination-reason runtime change is still in draft. The Dapr runtime maps the optional `reason` query parameter to its workflow termination request and exposes a supplied reason through `dapr.workflow.custom_status`.