Skip to main content
Version: 2.x

PHP SDK

Use durable-workflow/sdk when a PHP application or remote worker connects to the standalone Durable Workflow Server or a Durable Workflow Cloud namespace runtime URL. This first-party SDK is framework-neutral: it provides the control-plane client, authentication, transport, public payload codec, replay handler, and managed remote-worker lifecycle without requiring Laravel or the embedded engine package.

Try the local Sample App playground​

For the shortest no-Cloud authoring journey, open the current Sample App main branch in GitHub Codespaces and run:

scripts/playground php

The local playground generates caller-owned workflow and activity source, selects the current stable artifacts, and starts the published Server and Waterline. It waits for a worker registration whose identity, workflow type, activity type, and task queue match the generated contract before starting the workflow. Success requires the expected completed result and history; the terminal then prints the exact local Waterline run link and the path to structured JSON evidence.

The package-owned quickstart and API reference below remain the direct path for users who want to add the SDK to an existing project without Sample App.

For step-by-step onboarding, framework paths, testing, deployment, and troubleshooting, use the authored PHP developer portal. For exact constructor signatures, return types, and exception classes, use its distinct generated API reference. The portal's machine-readable contract identifies the package, runtime forms, role credentials, shipped source files, expected result, and published-artifact smoke as one tested path.

Cloud customers use the runtime URL and namespace returned during provisioning, with separate client and worker credentials. See Cloud Managed Runtime for that connection boundary; the examples below show the same SDK against local self-hosted values.

Use durable-workflow/workflow for the separate embedded Laravel path, where the application owns workflow state in its existing database and executes work through its Laravel queues. See Deployment Modes for the complete ownership comparison.

Requirements​

  • PHP 8.1 or later for the framework-neutral SDK
  • For the Laravel service-mode bridge in PHP SDK 3.10 and later: PHP 8.2 or later and Laravel 12.72 or later in 12.x, or Laravel 13.41 or later in 13.x with PHP 8.3 or later
  • A reachable self-hosted Server or provisioned Cloud namespace runtime

Install​

Install the current published PHP SDK. The exact requirement below is generated from the registry-refreshed published-artifact authority, and Composer records the resolved package in composer.lock:

composer require durable-workflow/sdk:3.33.0

The SDK uses the official apache/avro Composer package for the public payload envelope. Its production dependency graph excludes Laravel, Illuminate, durable-workflow/workflow, and durable-workflow/server.

Start and inspect a workflow​

The SDK-owned quickstart creates a clean Composer project, defines one attributed workflow and activity, starts the worker, starts a unique workflow, and waits for the result. The same shipped bootstrap.php, worker.php, and client.php files are installed from the package and executed by the protected published-artifact smoke, so this page does not maintain a second code listing.

Choose only the runtime connection value:

RuntimeValue passed to ClientSDK request path behavior
Self-hosted ServerBare origin such as http://localhost:8080Adds one /api segment; callers do not append /api.
Durable Workflow CloudComplete provisioned URI such as https://cloud.example/api/runtime/v1/namespaces/<runtime-id>Preserves the namespace runtime path and appends endpoint /api after it.

Open the tested PHP path for the exact commands and visible source. Client operations read DURABLE_WORKFLOW_CLIENT_TOKEN; worker polling reads DURABLE_WORKFLOW_WORKER_TOKEN. The guide keeps those credentials in separate processes without echoing or committing either value.

Worker::register() discovers #[Workflow] and #[Activity] handlers in the same source file. The guide also documents the direct registerWorkflow()/registerActivity() alternative for callable-first code. The bootstrap removes autoloader-path selection from users when those shipped files run in a standalone project, SDK checkout, installed package, or a playground/container that places them beside its Composer vendor/ directory.

WorkflowHandle follows the current run after a continue-as-new transition. Use its selected-run methods when an operation must remain guarded to one specific run.

Lifecycle, updates, schedules, and visibility​

The current public client is broader than selected-run result handling:

  • WorkflowHandle exposes describe, result, signal, query, cancel, and terminate, with selected-run variants for run-specific safety.
  • Client exposes listWorkflows with server filtering and pagination, workflowHistory, updateWorkflow, cancelWorkflow, and terminateWorkflow.
  • requestCancellation() requests bounded cleanup from cooperating workers. Existing cancel() and cancelWorkflow() close the run immediately. See cooperative cancellation for the authoring and recovery contract.
  • Schedule methods cover create, describe, list, update, pause, resume, trigger, backfill, and delete.
  • Operational visibility includes listNamespaces, listWorkers, and listTaskQueues, with matching describe methods.

Remote workers register workflow, activity, query, and update handlers through registerWorkflow, registerActivity, registerQuery, and registerUpdate. Use the generated PHP SDK API reference for complete parameters and return types.

Update validators​

PHP SDK 3.32.0 and later let a workflow refuse an update before it is accepted. Put #[UpdateValidator] on a method of the workflow class, next to its #[Update] handler. The low-level form is Worker::registerUpdateValidator($workflowType, $updateName, $callable), called after registerUpdate().

use DurableWorkflow\Attribute\Update;
use DurableWorkflow\Attribute\UpdateValidator;
use DurableWorkflow\Worker\QueryContext;

final class OrderWorkflow
{
#[Update('approve')]
public function approve(QueryContext $context, int $amount): int
{
return $amount;
}

#[UpdateValidator('approve')]
public function validateApprove(QueryContext $context, int $amount): void
{
if ($amount <= 0) {
throw new \DomainException('The amount must be positive.');
}
}
}

The validator takes a QueryContext with the run's committed history, followed by the update's arguments. The worker advertises the validator to the Server and polls workflow and update-validation tasks together. Registration is refused with update_validation_tasks_unavailable when the Server doesn't advertise synchronous update validation. For each validation task, the worker runs only the validator:

  • Returning normally approves the update, and the Server accepts it.
  • Throwing, or returning false, rejects it with update_validator_rejected, the exception message and class, and any field errors from an errors() method on the exception. The update is never accepted and its handler never runs. The Server records the rejection only as an UpdateRejected audit event.
  • Trying to schedule durable work is refused with UpdateValidatorCommandRefused, which rejects the update.

On the client, updateWorkflow() throws UpdateFailed. rejectedByValidator() identifies a validator rejection and validationErrors() returns its field errors. validationFailed() is true when the Server couldn't get a decision in time; nothing was accepted, so retry with the same request ID.

Validators never run during replay. Each validation sees only the history committed before its own task, so two validations running at the same time can both pass a check that only one of them should. A validator worker doesn't use carried workflow polls. Worker interceptors wrap update validation tasks through executeUpdateValidation(); they see the validator's decision but can't change it.

Replay-aware workflow logging​

The worker replays a workflow from its history on every workflow task, so an ordinary log call in workflow code repeats once for every completed step. PHP SDK 3.32.0 and later provide $context->logger(). It returns a PSR-3 logger that writes through the logger you pass to the Worker (the named logger argument), and only when the code runs past the run's committed history:

use DurableWorkflow\Worker\WorkflowContext;

function approve(WorkflowContext $context, string $orderId): string
{
$context->logger()->info('Approval started', ['order_id' => $orderId]);
$decision = $context->activity('review', [$orderId]);
$context->logger()->info('Review finished', ['decision' => $decision]);

return $decision;
}

Each line carries namespace, workflow_type, workflow_id and workflow_run_id. $context->replayState() returns WorkflowReplayState::Replaying, Executing or Unavailable, and isReplaying() is its boolean form. Use them for diagnostics only; never choose workflow commands from them.

Lines are written only after the Worker submits the workflow task that ran the code and the Server accepts it. A superseded replay, a speculative replay the Server declines and a refused completion write nothing. Code that parks on a pending child or operation handle without recording a step logs once, in the task that moves past the wait. A logger() call inside a side-effect closure writes nothing.

If the worker dies between the Server's acceptance and the write, those lines are lost. This is a process logger, not an outbox for business effects. Keep log handlers fast and non-blocking: a handler that waits on the network stalls the worker and can cost it the task lease. Logger failures are caught and never change the workflow's commands.

Activity retry context and owning run​

PHP SDK 3.6.1 or later exposes $context->retryInfo, $context->workflowId and $context->runId in service-mode activities. Check $context->retryInfo->isLastConfiguredAttempt() === true for the final configured attempt of a bounded policy. attemptNumber preserves the original received attempt number.

The retry snapshot preserves three distinct states: policyProvided === false means the claim omitted the policy; a provided root null is unknown legacy policy; an object with explicit max_attempts: null means unlimited. maxAttempts() returning null alone does not establish unlimited retries. The SDK does not invent a default budget. Cancellation, non-retryable failure, workflow closure and elapsed deadlines can end execution before the budget is exhausted.

The workflow and run IDs identify the original owning run. Missing legacy identity stays null. Local activities retain known parent IDs without inheriting a remote retry policy. To signal the owning workflow, require both IDs, pin the signal to runId and reuse a stable business-event request ID across retries.

Keep signal processing idempotent for the business event. A stable request ID alone does not establish once-only signal admission.

See the complete final-attempt and own-run signal examples in the PHP SDK guide.

Logical activity execution identity​

PHP SDK 3.10.0 or later exposes the read-only nullable ActivityContext::activityExecutionId received with an activity claim. It identifies the logical activity across retries. workflowId and runId identify its owning workflow instance and run; activityAttemptId identifies an attempt. Do not substitute a task, attempt or session ID for a missing logical execution ID.

The SDK preserves the received nonempty string exactly. Omitted, null, empty or non-string identity values produce null. Use an application-owned business key when it is unavailable. The SDK-owned service-key example shows that fallback; the property reference defines the public API. Scope keys to the application and effect, use distinct keys for distinct effects, and reconcile uncertain outcomes with the destination. Identity is public metadata, not claim authority or an exactly-once external-effects guarantee.

Ordinary and cooperatively supervised remote callbacks read the actual claim field. Session callbacks expose it only when their claim includes it. Inline local and Server-free callbacks without Server admission have null execution identity, even when their parent workflow/run IDs are known. Historical prepared-local source forwards its validated admission ID; that source behavior does not establish native prepared-local support. These are source/dataflow boundaries, not installed retry observations for every execution mode.

Activity heartbeats​

For remote activities, call ActivityContext::heartbeat($details) during bounded work, well before the configured heartbeat timeout. The first window starts at runtime claim, not when PHP receives the task. Request latency, pauses and transport retries consume that window. Follow the cadence guidance.

The method returns void. In the direct handler path, a stop reply raises ActivityCancelled. HTTP and transport failures from Client::heartbeatActivityTask() surface as ServerException. A cooperatively supervised worker can stop or abandon its callback when a heartbeat or ownership check fails instead of delivering a normal response to activity code. Do not assume cleanup code always runs. Do not suppress a failure after losing the claim or submit success after losing authority.

Resume from an acknowledged heartbeat​

When the worker and Server support heartbeat resume version 1, a heartbeat with application details can commit a checkpoint for the logical activity execution. At the start of a retry, use $context->lastHeartbeatCheckpoint() to read the fixed snapshot and its original acknowledgement time. A supported claim with no recorded details returns null. A context without the contract reports ActivityHeartbeatResumeUnavailable.

If a heartbeat acknowledgement is lost, resume from what Server committed. Activity retry policy and deadlines still apply. Use stable idempotency keys and check the provider’s receipt before repeating an external operation. The external operation has its own commit boundary. Activity retries and idempotency. SDK checkpoint example.

When an external operation requires exclusive ownership, have the provider reject stale fencing tokens.

Run a remote PHP worker​

Workflow handlers are ordinary callables that run as straight-line code inside a managed Fiber. Call operations such as WorkflowContext::activity() directly; the SDK suspends the Fiber at durable decisions and returns recorded results during replay without repeating external activity. Do not declare a workflow as a Generator or yield WorkflowContext commands: Generator results are rejected. The managed worker registers its workflow and activity type names, polls the public worker protocol, heartbeats, completes or fails tasks, and handles graceful shutdown when pcntl is available.

First-completion selection​

Use WorkflowContext::select() to start independent deferred activities, child workflows, timers, condition waits, or nested ordinary barriers and resume from the first durably committed winner. The returned SelectionResult contains stable member keys and identities plus one handle per member:

$selected = $ctx->select([
'resolver' => fn () => $ctx->activity('resolve-request', [$requestId]),
'input' => fn () => $ctx->waitCondition(
fn (): bool => $this->resolution !== null,
key: 'resolution-ready',
),
'deadline' => fn () => $ctx->sleep(2),
]);

if ($selected->key === 'deadline') {
$selected->handles['resolver']->cancel();
}

Selection does not cancel non-winners. Call await() on a handle to consume its eventual result or cancel() to record explicit cancellation. A cold worker or completed-history replay consumes the recorded winner even when duplicate or later input and terminal events appear in another delivery order. cancel() returns void and does not report its terminal outcome. Only SelectionOperationCancelled history proves cancellation won; replay advances past an unmarked cancel request, and if the operation completed first, await() still returns that result.

Durations​

From PHP SDK 3.9.0, workflow timers and timeouts take the same duration forms as the embedded Laravel package. sleep(), deferTimer(), the timeout of waitCondition() and deferCondition(), the activity timeout options, the child workflow execution_timeout_seconds and run_timeout_seconds options and the service operation wait_timeout_seconds option accept int or float seconds, a string such as '30 minutes', or a DateInterval or CarbonInterval:

use Carbon\CarbonInterval;

$verified = $ctx->waitCondition(
static fn (): bool => $ctx->signals('verify') !== [],
key: 'email-verified',
timeout: '30 minutes',
);

$ctx->sleep(CarbonInterval::hours(2));

$receipt = $ctx->activity('payments.capture', [$orderId], [
'start_to_close_timeout' => '30 seconds',
'schedule_to_close_timeout' => '10 minutes',
]);

Each value converts once to whole seconds, rounding up, so '30 minutes', 1800 and CarbonInterval::minutes(30) record the same history. Strings convert exactly as the embedded timer() and await() do. The SDK rejects ISO 8601 strings such as 'PT30M' (pass new DateInterval('PT30M') instead), negative values, fractions of a month or a longer calendar unit, parts with more than 15 integer digits, and unparseable text. A numeric string such as '30' keeps its earlier meaning: timers and condition timeouts round it up to whole seconds, and activity and child workflow options pass it through unchanged. A zero duration is valid for timers, condition waits and wait_timeout_seconds; activity and child workflow timeouts need at least one second. Earlier SDK releases accept seconds only. PHP SDK 3.9.0 adds nesbot/carbon (^2.72.6|^3.8.4) as a required dependency, so durations convert with the same parser as the embedded package. The PHP SDK duration reference lists every unit.

Replay-safe workflow time​

WorkflowContext::replayNow() returns replay-safe UTC business time as a DateTimeImmutable. At ordinary entry it is the run's start (for a redrive successor, the original run's start) from the task's replay_clock (Server 3.6.0 and later). After each supported consumed durable step (activities, timers, child workflows, condition waits, validated groups) it is that step's recorded time. Repeated reads between durable steps return the same value, and every replay returns the same values.

Where the SDK cannot prove the time, it throws DurableWorkflow\Exception\ReplayClockUnavailable. That includes side effects, version markers and local activities, which stay unavailable until Core defines a persisted time for them. A clock read right after such a step is not portable across runners or mixed fleets; see Clock reads after inline steps are not portable. Query and update handlers read history snapshots and never rebuild the workflow body. See the cross-SDK clock semantics for the full list, release status and the upgrade note.

Entry compatibility and recovery​

Released support. PHP SDK 2.5.4 introduced the entry safeguard below, with routing and recovery support in Server 2.9.9. These are minimum feature versions; install current stable releases for security fixes.

The managed worker checks the handler's recorded positional input before entering its Fiber. Missing required arguments or incompatible declared PHP types raise DurableWorkflow\Exception\WorkflowEntryArgumentsMismatch and report the task reason workflow_entry_arguments_mismatch. Optional defaults apply only to omitted input; they never replace an incompatible recorded value. A TypeError thrown after successful entry remains an application failure.

The worker advertises workflow_entry_arguments_validation automatically. With the matching Server support, a refused task is replay-blocked and the original run stays nonterminal. An older runtime may instead retry the failed task, so an SDK upgrade alone does not establish the complete recovery contract.

Inspect the original with Client::describeWorkflow($workflowId, $runId) and the selected-run debug endpoint. Restore compatible code before calling Client::repairWorkflow($workflowId, $runId), then verify that same run resumes without changing input, history, routing identity or deadlines. Do not catch this failure inside the workflow body or repeatedly repair incompatible code. See the service recovery procedure and definition routing.

Framework service mode and embedded Laravel​

The same package ships first-party Laravel service-mode and Symfony service-mode bridges. They retain framework dependency injection, configuration, logging, console workers, and test fakes while connecting to Cloud or Server.

Those bridges are distinct from embedded Laravel workflows, where durable-workflow/workflow makes the Laravel application itself own durable state and execute through Laravel queues. See Laravel Adoption and Runtime Transition for the same representative Laravel use case across v1, v2 embedded, and this shipped service-mode bridge, including drain and rollback. Use Deployment Modes for the wider runtime boundary comparison.

Worker interceptors​

Worker interceptors are available in PHP SDK 3.32.0 and later. Pass ordered interceptors to Worker::create() (or the Worker constructor) to add audit logging, metric tags, tenant context or tracing around every task once, instead of in each handler. Each interceptor implements DurableWorkflow\Worker\Interceptor\WorkerInterceptor; extend PassthroughWorkerInterceptor to implement only the hooks you need. The hook shape matches the Python and Rust SDK interceptors.

This audit interceptor logs every workflow task outcome and activity attempt:

use DurableWorkflow\Worker;
use DurableWorkflow\Worker\Interceptor\ActivityInterceptorContext;
use DurableWorkflow\Worker\Interceptor\PassthroughWorkerInterceptor;
use DurableWorkflow\Worker\Interceptor\WorkflowTaskInterceptorContext;
use DurableWorkflow\Worker\Interceptor\WorkflowTaskOutcome;
use Psr\Log\LoggerInterface;

final class AuditInterceptor extends PassthroughWorkerInterceptor
{
public function __construct(private readonly LoggerInterface $audit)
{
}

public function executeWorkflowTask(WorkflowTaskInterceptorContext $context, callable $next): WorkflowTaskOutcome
{
$outcome = $next($context);
$this->audit->info('workflow task', [
'workflow_id' => $context->workflowId,
'workflow_type' => $context->workflowType,
'attempt' => $context->workflowTaskAttempt,
'replayed_history' => $context->replaying,
'commands' => $outcome->commandTypes(),
]);

return $outcome;
}

public function executeActivity(ActivityInterceptorContext $context, callable $next): mixed
{
$this->audit->info('activity started', [
'activity_type' => $context->activityType,
'attempt' => $context->attemptNumber,
'workflow_id' => $context->workflowId,
]);
try {
return $next($context);
} finally {
$this->audit->info('activity finished', ['activity_type' => $context->activityType]);
}
}
}

$worker = Worker::create($client, 'orders', container: $container,
interceptors: [AuditInterceptor::class]);
HookContext$next returns
executeWorkflowTask($context, $next)workerId, taskQueue, namespace, task, taskId, workflowType, workflowId, runId, workflowTaskAttempt, historyLength, replaying (also replayState()), updateId, observabilitySupportedWorkflowTaskOutcome with a copy of the commands
executeActivity($context, $next)workerId, taskQueue, namespace, task, activityType, arguments, attemptNumber, taskId, activityAttemptId, workflowId, runId, local, activityContext, observabilitySupportedthe activity result
executeQueryTask($context, $next)workerId, taskQueue, namespace, task, taskId, workflowType, queryName, workflowId, runId, arguments, queryContext, observabilitySupportedthe query result
executeUpdateValidation($context, $next)workerId, taskQueue, namespace, task, taskId, workflowType, updateName, workflowId, runId, arguments, queryContext, observabilitySupportedUpdateValidationOutcome with approved, reason, message, failureType, validationErrors

Interceptors run in the order you list them. The first interceptor is the outermost wrapper: it runs first before the task and last after it. Each hook calls $next($context) to continue the chain. When tracing is configured, the built-in worker spans stay outermost, so interceptors run inside the active task span.

Workflow-task interceptors cannot break determinism:

  • executeWorkflowTask wraps the workflow code that produces one workflow task's commands, once per task attempt. replaying is true when earlier workflow tasks already recorded commands, so the workflow code re-ran that committed prefix first. The outcome holds only the commands this task adds; replayed commands are never resubmitted.
  • replayState() reports the same thing as the WorkflowReplayState that WorkflowContext::replayState() uses: Replaying or Executing.
  • A retried attempt (workflowTaskAttempt > 1) can repeat an outcome whose task failed, so make external audit writes idempotent.
  • Update tasks (updateId set) run the update handler against committed state without re-running the workflow body; for them replaying only reports that earlier commands exist.
  • The worker submits exactly the commands the workflow code produced. The outcome is a copy; returning a different outcome, or passing a different context to $next, changes nothing.
  • A failure from the workflow code reaches the worker unchanged, even if an interceptor catches it and returns normally.
  • An exception thrown by an interceptor fails the workflow task. Nothing is recorded and the Server retries the task. Skipping $next, or calling it more than once, fails the task with WorkflowTaskInterceptorViolation.

Update-validation interceptors (executeUpdateValidation()) wrap the run of an update's validator before the Server accepts the update. They see the decision as a read-only UpdateValidationOutcome and cannot change the decision, the update's arguments or the history the validator reads: the validator always runs read-only in its own Fiber with the worker's copy of the task, and the worker answers with the validator's own decision. An exception from the interceptor, or skipping $next or calling it more than once (UpdateValidationInterceptorViolation), answers the task with update_validation_worker_failed, so the update is not accepted and the caller can retry.

Activity and query interceptors may change arguments with $context->withArguments(...) and may change the returned value, because activity results are recorded once and queries record nothing. Activity exceptions pass through every interceptor unless one handles them. Activity interceptors wrap remote and local activities; local tells them apart. With cooperative cancellation, remote, cooperative local and prepared local activity callbacks and their interceptors run in the activity's child process, so memory changes there do not reach the worker process.

Container and framework configuration​

Pass interceptor instances or class names. Class names are resolved from the PSR-11 container passed to the worker, the same way attributed handlers are. Without a container, a class name must have no required constructor arguments.

In Laravel and Symfony service mode, list interceptor classes under worker.interceptors. They are resolved from the framework container in that order:

// config/durable-workflow.php
'worker' => [
'interceptors' => [App\Durable\AuditInterceptor::class],
],
# config/packages/durable_workflow.yaml
durable_workflow:
worker:
interceptors:
- App\Durable\AuditInterceptor

Embedded Laravel workflows configure their own interceptors under workflows.v2.interceptors; see embedded worker interceptors. The PHP SDK reference has the full interceptor contract.

Query results with binary values​

PHP SDK 3.18.2 fixes query completion for valid Avro results containing nested AvroBinaryValue bytes. The result_envelope remains authoritative. The SDK omits only the optional plain result projection when it cannot be JSON encoded; ordinary JSON-compatible results keep that projection.

Published PHP 3.18.2 / native Server 3.9.1 installed controls (PHP 8.3.36, linux/amd64, SQLite) verify an actual Worker round-trip for nested binary bytes, ordinary JSON, signed zero and null, plus workflow completion and graceful Worker deregistration. This is a compatible query fix; it does not add a capability or establish full request-key or timeout-cleanup support. See the PHP query guide.

Read an accepted update later​

The selected PHP SDK 3.33.0 supports reading a retained update by its stable ID without admitting it again. Client::updateOutcome($workflowId, $updateId) defaults to waitFor: 'completed': pending work throws UpdateStillPending; a completed result may legitimately be null. updateOutcomeReceipt() defaults to waitFor: 'accepted' and returns the Server receipt so callers can inspect update_status and wait_timed_out separately from a completed result.

These GET reads require the update_outcome_reads capability (native Server 3.6.0 and later). Without it, the SDK throws LogicException and does not resubmit the update. An initial updateWorkflow() pending exception retains the caller's request ID. A pending GET read retains updateId, but its original request key may be unavailable: $pending->requestId is then '', meaning unknown. Continue reading with that update ID; never submit an empty, inferred or internal hashed key as the original request ID.

The published PHP guide shows the workflow-side handler and client journey. Installed PHP 3.18.1 / native Server 3.9.1 controls verify pending-to-completed-null reads without a second update admission, plus completion-size handling. This evidence does not establish full request-key acceptance under shared #216 or native timeout-cleanup support.

Upgrade to PHP SDK 3.12 through 3.14​

PHP ^8.1, the Laravel bridge floors, worker protocol 1.20 and control plane 2 are unchanged from 3.11. Check these behavior changes before deploying:

  • Updates that outlast their wait. From 3.13, when a waitFor: 'completed' update wait ends before the update finishes, Client::updateWorkflow() and WorkflowHandle::update() throw UpdateStillPending. Earlier releases returned the Server receipt as if it were the update's result. To keep waiting, call the update again with $pending->requestId. That does not apply the update twice.
  • Stale worker registration. From 3.13, Worker::run() registers again after stale_worker_registration instead of stopping. Tasks the fenced worker held are dropped without completing, and the Server redelivers them. Each recovery logs worker.reregistered and increments durable_workflow_worker_reregistrations. Pass stopOnStaleRegistration: true to keep the old behavior.
  • Local activity backoff. From 3.13, a local activity with more retries than backoff_seconds entries repeats the last delay instead of retrying immediately, as Server-scheduled activities do.
  • Condition waits in groups on native Server. Native Server doesn't accept a condition or signal wait inside all() or parallel() yet. From 3.13.1, the worker fails that workflow task with grouped_condition_wait_unsupported and keeps running, instead of exiting. Await the condition outside the group.

New in these releases:

  • Sticky history suffixes (3.14). Workers advertise sticky_history_suffix. On Server 3.5.0 or later, a worker that already holds a run's history receives only the events after the sequence it cached. A suffix that doesn't continue the cached history exactly is dropped and the full history is fetched. Older Servers keep sending full history.
  • Schedule origin (3.13). WorkflowContext::scheduleOrigin() returns the schedule id, occurrence time and trigger number of the schedule fire that started the run, or null for an ordinary start. The value is the same on replay. From Server 3.5.0, a run that continues as new keeps its schedule origin.
  • Activity continuations (3.12). Pass enableActivityContinuation: true to the Worker constructor to submit the next workflow commands together with a successful activity result when the Server advertises activity_workflow_continuation (native Server 3.4.0 or later). It defaults to false. Turning it on currently costs throughput: in our benchmark under load, workflows ran 24–49% slower with it on and used twice as many database transactions (measurement). Use 3.12.1 or later if you enable it, and drain or disable opted-in workers before downgrading the Server or adding older Server nodes.

See the 3.14.0 changelog for the complete list.

Upgrade to PHP SDK 3.10 and 3.11​

Read the PHP SDK upgrade guide before deploying. Upgrade every worker that can receive work from a task queue together, including standby and autoscaling pools.

  • Laravel bridge. From 3.10, the Laravel service-mode bridge follows Workflow 2.21: PHP ^8.2 and patched Laravel ^12.69.0|^13.30.0. Laravel 10 and 11 are no longer supported. The provider refuses unsupported or unknown framework and PHP versions before registering anything. The bare SDK keeps PHP ^8.1 and Symfony 6.4/7/8 support.
  • Condition fingerprints. From 3.10, new condition waits record v2 (dwphp2:sha256:) predicate fingerprints. Older workers reject them, so rolling workers back below 3.10 after v2 waits exist can fail replay. Stop or drain older workers before replacements start, deploy PHP sources atomically and restart every long-running worker, including workers using OPcache. Workers that replay v2 waits need PHP's tokenizer. Existing v1 waits still require an exact source-line match.
  • Static credentials. From 3.10, static credentials are validated as given. Malformed UTF-8, Unicode whitespace at either edge and embedded control characters now fail instead of being trimmed or ignored. Check shared, client, worker and framework process-handoff values before upgrading.
  • Occurrence deadlines. In 3.11, a new top-level condition wait keeps its first deadline across false wakes when the Server advertises condition_wait_occurrence_deadline (native Server 3.3.0 or later). Without that capability, workers send the same commands as before. Grouped condition waits do not opt in yet. On an older Server, upgrade every worker on the queue to 3.11 before upgrading the Server. On a Server that already advertises the capability, drain or stop every older worker before any 3.11 worker consumes the queue. Once an anchored wait exists, do not roll that queue's workers back below 3.11.

PHP SDK 3.10 also adds WorkflowContext::startChildWorkflow(), which returns a ChildWorkflowHandle once the child start commits and needs a runtime that advertises child_workflow_start_turn. Other additions are ActivityContext::activityExecutionId, optional typed declarations for upsertSearchAttributes(), lazy workflow list and history iterators, and the enableCompletionPipelining Worker option, which defaults to false. Completion-carried polls are used only when the runtime advertises them. See the 3.11.0 changelog for the complete list.

Protocol and release boundary​

The SDK declares its supported server range, worker protocol version, control-plane version, and payload codecs in Composer metadata. The server also publishes its accepted protocol and codec set from GET /api/cluster/info. Check runtime discovery during deployment instead of inferring compatibility from a server patch version.

The PHP SDK is versioned independently from the Laravel package. Keep the exact published pin in runnable examples and evaluate release notes when upgrading SDK releases. Compatibility follows the SDK's declared contract, not matching package version numbers.

Open runs on a version branch​

PHP SDK 3.19.0 and later provide Client::workflowVersionUsage($workflowType, $changeId, $minVersion, $state, $limit, $cursor). It returns a typed page of open runs: counts for legacy, current and unknown runs, each run's state, recorded version and unknown reason, and an opaque nextCursor. It requires a Server that advertises capabilities.workflow_version_usage (Server 3.12.0 or later). Older Servers raise ServerCapabilityUnavailable before any usage request is sent. Use it for the version-usage check before you retire a version branch.

Workflow list and history pages​

These published calls return one page, not an automatic complete read: Client::listWorkflows(...) / Client::workflowHistory(...). Continue with the returned opaque token while keeping namespace, filters and selected workflow/run fixed; stop at the final null/empty token and handle page errors explicitly. A partial page is not a replay bundle. Use the SDK history-export API for offline replay. The published PHP 3.2.0 client source defines the page parameters.

PHP SDK 3.10.0 and later also provide Client::iterateWorkflows() and Client::iterateWorkflowHistory(). They read a complete workflow listing or exact-run history lazily, one page at a time, keeping the opaque cursor, namespace and filters. Errors on later pages propagate, and malformed continuations or token cycles are refused instead of truncating or looping. See the published PHP 3.11.0 client source.

A normal registry-installed observation on PHP SDK 3.18.2 and native Server 3.8.0 returned 5 filtered workflows over 3 two-item list pages and all 3 original-run history events over 2 two-item pages. It checked lazy construction and first yield, foreign-type exclusion and Worker deregistration. See the installed proof and PHP client guide. This evidence stays bound to its named tuple; it does not qualify another binding or runtime.

Bounded failure reports​

PHP SDK 3.5.0 introduced bounded outgoing failure reports. Defaults are 62 KiB UTF-8 for the message, 128 KiB for the stack, 64 KiB for combined serialized optional details and diagnostics, and 1 MiB for the complete JSON-encoded body. Markers, JSON escaping, claim identity and other commands in the batch count toward that body limit. A lower configured or transport-declared limit takes precedence. Failure type, class, code, retry policy and claim identity are preserved.

withFailureReportLimit() returns a new client with a smaller whole-request budget, from 1 to 1,048,576 bytes. Use the returned instance. A lower transport-declared cap also applies.

<?php

use DurableWorkflow\Client;

$client = (new Client(
baseUri: 'https://workflow.example.com',
controlToken: 'operator-token',
workerToken: 'worker-token',
))->withFailureReportLimit(512 * 1024);

A visible truncation marker and original byte counts identify shortened fields. Avro details remain intact or are omitted whole. An unrepresentable required envelope raises DurableWorkflow\Exception\FailureReportRefused before HTTP submission. Local failures are normalized before workflow code observes them, so first execution and cold replay see the persisted message. An already observed local message remains immutable during final batch fitting.