PHPackages                             durable-workflow/sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. durable-workflow/sdk

ActiveLibrary[Queues &amp; Workers](/categories/queues)

durable-workflow/sdk
====================

Framework-neutral PHP client and worker SDK for the Durable Workflow server

0.1.16(1mo ago)110.0k—3.9%[3 issues](https://github.com/durable-workflow/sdk-php/issues)MITPHPPHP ^8.1CI passing

Since Jul 13Pushed 1w agoCompare

[ Source](https://github.com/durable-workflow/sdk-php)[ Packagist](https://packagist.org/packages/durable-workflow/sdk)[ Docs](https://durable-workflow.com)[ RSS](/packages/durable-workflow-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (18)Versions (44)Used By (0)

Durable Workflow PHP SDK
========================

[](#durable-workflow-php-sdk)

The first-party, framework-neutral PHP SDK for applications and remote workers that connect to a standalone [Durable Workflow server](https://github.com/durable-workflow/server). It targets PHP 8.1 or newer and does not require Laravel or the embedded `durable-workflow/workflow` engine.

Choose the PHP execution model
------------------------------

[](#choose-the-php-execution-model)

- **Laravel adoption:** start with the [ownership-first transition guide](https://php.durable-workflow.com/frameworks/laravel/) when moving a Laravel Workflow v1 application to v2 embedded or service mode, or when moving embedded v2 to service mode. Laravel 9 through 13 are supported on both v2 destinations.
- **Plain PHP service mode:** follow the quickstart below when a framework-neutral application and remote worker connect to Durable Workflow Cloud or a self-hosted Server.
- **Symfony service mode:** use the [Symfony bridge](#symfony-service-mode) from this SDK for autowired remote handlers and a managed console worker.
- **Embedded Laravel workflows:** use [`durable-workflow/workflow`](https://php.durable-workflow.com/frameworks/laravel/)when the Laravel application itself should own durable state and execute through Laravel queues. That is a different deployment model, not a prerequisite for this SDK.

Plain PHP quickstart
--------------------

[](#plain-php-quickstart)

Create an empty Composer project and install the current published package:

```
mkdir durable-php-quickstart
cd durable-php-quickstart
composer init --name=acme/durable-php-quickstart --no-interaction
composer require 'durable-workflow/sdk:^2.0@RC'
```

The current 2.0 RC declares its verified Server baseline in package metadata; using another Server prerelease requires separate conformance evidence. Earlier 2.0 prereleases and pre-1.0 SDK releases remain historical rather than alternate supported baselines.

To install directly from the source repository before a tagged release:

```
composer config repositories.durable-workflow-sdk vcs https://github.com/durable-workflow/sdk-php
composer require durable-workflow/sdk:dev-main
```

The SDK uses the official [`apache/avro`](https://packagist.org/packages/apache/avro)package for schema parsing and binary payload encoding. Guzzle is included as the default PSR-18 transport; any PSR-18 client and PSR-17 factories can be injected instead.

### Choose Cloud or Server without rewriting the URL

[](#choose-cloud-or-server-without-rewriting-the-url)

Set one runtime URI exactly as provisioned:

```
# Self-hosted Server: pass the bare origin. The SDK appends one /api segment.
export DURABLE_WORKFLOW_RUNTIME_URL='http://localhost:8080'
export DURABLE_WORKFLOW_NAMESPACE='default'

# Durable Workflow Cloud: instead use both values returned by provisioning.
# export DURABLE_WORKFLOW_RUNTIME_URL='https://cloud.example/api/runtime/v1/namespaces/'
# export DURABLE_WORKFLOW_NAMESPACE=''

export DURABLE_WORKFLOW_TASK_QUEUE="php-quickstart-$(php -r 'echo bin2hex(random_bytes(8));')"
```

The Cloud URL already contains `/api/runtime/v1/namespaces/...`; do not trim that prefix or replace it with the Cloud control-plane URL. Keep the separately provisioned Cloud namespace value unchanged as well. The SDK appends its endpoint `/api` after the namespace runtime URI. For Server, pass an origin such as `http://localhost:8080`, not `http://localhost:8080/api`, so the request path contains one `/api` segment rather than two.

Inject credentials through the process environment or a secret manager. Client operations and worker polling are separate roles, so keep their variables separate even when a development Server is configured with one shared token:

```
read -rsp 'Client credential: ' DURABLE_WORKFLOW_CLIENT_TOKEN; echo
export DURABLE_WORKFLOW_CLIENT_TOKEN
read -rsp 'Worker credential: ' DURABLE_WORKFLOW_WORKER_TOKEN; echo
export DURABLE_WORKFLOW_WORKER_TOKEN
```

The prompts do not echo values. Do not put these exports in source files, commit an `.env` file, or print either value in diagnostics.

### Create the three example files

[](#create-the-three-example-files)

`bootstrap.php` resolves Composer consistently when the example is in a clean project, this SDK checkout, an installed SDK package, or a Sample App playground/container that copies the files beside its own `vendor/` directory.

```
