PHP client and worker SDK for Durable Workflow Cloud and self-hosted Server
Requires
- php: ^8.1
- composer-runtime-api: ^2.0
- ext-json: *
- apache/avro: ^1.12
- guzzlehttp/guzzle: ^7.8|^8.0
- psr/container: ^1.1|^2.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.1|^2.0
- psr/log: ^1.1|^2.0|^3.0
Requires (Dev)
- phpdocumentor/phpdocumentor: ^3.7
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.5|^11.0
Suggests
- ext-pcntl: Required by framework console workers for graceful SIGINT and SIGTERM handling.
- laravel/framework: Enables the auto-discovered Laravel 9 through 13 service-mode bridge.
- symfony/console: Required with symfony/framework-bundle to run the Symfony 6.4, 7, and 8 worker command.
- symfony/framework-bundle: Enables the Symfony 6.4, 7, and 8 service-mode bundle.
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-rc.54
- 2.0.0-rc.53
- 2.0.0-rc.52
- 2.0.0-rc.51
- 2.0.0-rc.50
- 2.0.0-rc.49
- 2.0.0-rc.48
- 2.0.0-rc.47
- 2.0.0-rc.46
- 2.0.0-rc.45
- 2.0.0-rc.43
- 2.0.0-rc.42
- 2.0.0-rc.41
- 2.0.0-rc.40
- 2.0.0-rc.39
- 2.0.0-rc.38
- 2.0.0-rc.37
- 2.0.0-rc.36
- 2.0.0-rc.35
- 2.0.0-rc.34
- 2.0.0-rc.32
- 2.0.0-rc.31
- 2.0.0-rc.30
- 2.0.0-rc.14
- 2.0.0-rc.13
- 2.0.0-rc.12
- 2.0.0-rc.11
- 2.0.0-rc.10
- 2.0.0-rc.9
- 2.0.0-rc.8
- 2.0.0-rc.7
- 2.0.0-rc.6
- 2.0.0-rc.5
- 2.0.0-rc.4
- 2.0.0-rc.3
- 2.0.0-rc.1
- 2.0.0-beta.21
- 2.0.0-beta.18
- 2.0.0-beta.17
- 2.0.0-beta.16
- 2.0.0-beta.14
- 2.0.0-beta.13
- 2.0.0-beta.10
- 2.0.0-beta.6
- 2.0.0-beta.5
- 2.0.0-beta.4
- 2.0.0-beta.3
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-fix/upstream-http-errors
- dev-fix/poll-backpressure-fairness
- dev-fix/leased-external-payload-draining
- dev-fix/runtime-payload-uploads
- dev-release/2.0.7
- dev-fix/worker-database-unavailable
- dev-fix/self-contained-published-smoke
- dev-fix/runtime-external-payloads
- dev-fix/worker-connection-recovery
This package is auto-updated.
Last update: 2026-09-12 20:17:44 UTC
README
The first-party PHP client and worker SDK for Durable Workflow Cloud and self-hosted Durable Workflow Server. Use it from plain PHP, Laravel, or Symfony to run durable workflows outside the application process while keeping framework-native configuration, dependency injection, commands, logging, and tests.
Install
composer require durable-workflow/sdk:^2.0
The SDK requires PHP 8.1 or newer. It uses the official apache/avro package
for portable payloads and accepts any PSR-18 HTTP client.
Choose Your Path
| Starting point | Recommended guide |
|---|---|
| Plain PHP client or worker | First workflow |
| Laravel v1 or v2 embedded | Choose a Laravel ownership model |
| Laravel service mode | Laravel service-mode bridge |
| Symfony service mode | Symfony bundle |
| Runtime authentication | Authentication guide |
Laravel applications can keep Durable Workflow embedded or move execution to Cloud or Server. The service-mode bridge supplies container bindings, config, an Artisan worker command, diagnostics, a facade, and a test fake. Symfony gets the same application-shaped experience through its bundle and Console worker.
Author a Workflow
Handlers can be ordinary attributed classes resolved by the worker container:
<?php use DurableWorkflow\Attribute\Activity; use DurableWorkflow\Attribute\Workflow; use DurableWorkflow\Worker\ActivityContext; use DurableWorkflow\Worker\WorkflowContext; final class GreetingWorkflow { #[Workflow('example.greeting')] public function run(WorkflowContext $context, string $name): array { $greeting = $context->activity('example.greet', [$name]); return ['greeting' => $greeting]; } } final class GreetingActivities { #[Activity('example.greet')] public function greet(ActivityContext $context, string $name): string { return "Hello, {$name}"; } }
Register the classes on a task queue and start polling:
use DurableWorkflow\Client; use DurableWorkflow\Worker; $client = new Client( getenv('DURABLE_WORKFLOW_RUNTIME_URL'), namespace: getenv('DURABLE_WORKFLOW_NAMESPACE'), workerToken: getenv('DURABLE_WORKFLOW_WORKER_TOKEN'), ); Worker::create($client, 'greetings') ->register(GreetingWorkflow::class, GreetingActivities::class) ->run();
Start the workflow from a client process using a client-role credential:
$client = new Client( getenv('DURABLE_WORKFLOW_RUNTIME_URL'), namespace: getenv('DURABLE_WORKFLOW_NAMESPACE'), controlToken: getenv('DURABLE_WORKFLOW_CLIENT_TOKEN'), ); $handle = $client->startWorkflow( workflowType: 'example.greeting', workflowId: 'greeting-'.bin2hex(random_bytes(12)), taskQueue: 'greetings', input: ['PHP'], ); var_dump($handle->result());
For Cloud, use the complete namespace runtime URL exactly as provisioned. For
self-hosted Server, use its origin such as http://localhost:8080. Keep client
and worker credentials in separate processes.
The complete plain PHP quickstart includes the three runnable files, environment setup, expected output, and common failure diagnostics.
Capabilities
- Workflows, activities, child workflows, timers, retries, and heartbeats
- Signals, queries, updates, condition waits, and message streams
- Parallel work, sagas, cancellation, continue-as-new, and version markers
- Schedules, search attributes, memo, external payloads, and worker versioning
- Replay testing, in-memory client fakes, Laravel and Symfony test helpers
- Stable workflow handles and machine-readable runtime diagnostics
See the complete SDK reference for control-plane APIs, worker configuration, Message Streams, framework setup, and testing examples. The generated API reference documents every public class and method.
Development
composer install
composer test
composer analyse
composer benchmark-avro-value
See CONTRIBUTING.md for contribution and validation details.
License
MIT