Skip to content

Commit 19040f7

Browse files
deploy: 379f154
1 parent df9b1f4 commit 19040f7

280 files changed

Lines changed: 1331 additions & 1256 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2.0/llms-full.txt

Lines changed: 89 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,89 @@ This is the state machine for a workflow status.
341341

342342
<!-- Source: docs/defining-workflows/workflow-authoring-reference.md -->
343343

344-
# Workflow Authoring API Reference
344+
# Workflow API
345345

346-
The v2 PHP authoring API is the code surface that runs inside a workflow
347-
fiber. Application workflows extend `Workflow\V2\Workflow`, implement a
348-
`handle()` entry method, and use either the static `Workflow::...` facade or
349-
the equivalent `Workflow\V2\...` helper functions for durable commands.
346+
This page is the compact lookup for the stable v2 PHP authoring surface that
347+
runs inside a workflow fiber. Most humans should learn the pattern first from
348+
the narrative pages, then come back here only when they need the exact method,
349+
argument shape, or return contract.
350350

351-
This page is a signature reference. For narrative guidance, see
352-
[Workflows](./workflows.md), [Activities](./activities.md),
353-
[Signals](../features/signals.md), and [Message Streams](../features/message-streams.md).
351+
## Read This Page When
354352

355-
## Base Workflow Class
353+
- You already know the authoring pattern and only need the exact API shape.
354+
- You want to confirm whether a call is a workflow helper, base-class method,
355+
attribute, or `Workflow\V2\MessageStream` operation.
356+
- You are wiring snippets, code generation, or an AI assistant against the
357+
stable v2 PHP workflow surface.
358+
359+
If you are still choosing the pattern, start with the narrative guides instead:
360+
361+
- [Workflows](./workflows.md) for the workflow class shape and deterministic
362+
orchestration model.
363+
- [Activities](./activities.md) for side effects, retries, and routing.
364+
- [Signals](../features/signals.md), [Updates](../features/updates.md), and
365+
[Queries](../features/queries.md) for workflow-facing contracts.
366+
- [Timers](../features/timers.md),
367+
[Condition Waits](../features/condition-waits.md), and
368+
[Continue As New](../features/continue-as-new.md) for long-running control
369+
flow.
370+
- [Message Streams](../features/message-streams.md) for repeated ordered
371+
messages with cursor semantics.
372+
373+
## What Most Authors Actually Use
374+
375+
Most teams only touch a small part of the surface on a normal workflow:
376+
377+
| Need | API to reach for | Learn the pattern first |
378+
| --- | --- | --- |
379+
| Run side effects and wait for results | `Workflow::activity()` | [Activities](./activities.md) |
380+
| Wait on time, a signal, or a condition | `Workflow::timer()`, `Workflow::await()`, `Workflow::awaitSignal()` | [Timers](../features/timers.md), [Signals](../features/signals.md), [Condition Waits](../features/condition-waits.md) |
381+
| Start a child workflow | `Workflow::child()` | [Child Workflows](../features/child-workflows.md) |
382+
| Rotate a long history | `Workflow::continueAsNew()` | [Continue As New](../features/continue-as-new.md) |
383+
| Evolve replay-safe code | `Workflow::getVersion()`, `Workflow::patched()` | [Versioning](../features/versioning.md) |
384+
| Exchange repeated ordered messages | `$this->inbox()`, `$this->outbox()` | [Message Streams](../features/message-streams.md) |
385+
| Publish operator metadata | `Workflow::upsertSearchAttributes()`, `Workflow::upsertMemo()` | [Search Attributes](../features/search-attributes.md), [Memo](../features/memo.md) |
386+
387+
The most common shape is still small:
388+
389+
```php
390+
use Workflow\V2\Workflow;
391+
392+
final class FulfillmentWorkflow extends Workflow
393+
{
394+
public function handle(string $orderId): array
395+
{
396+
Workflow::upsertSearchAttributes([
397+
'order_id' => $orderId,
398+
'status' => 'packing',
399+
]);
400+
401+
$label = Workflow::activity(CreateShippingLabel::class, $orderId);
402+
$approval = Workflow::awaitSignal('approved-by');
403+
$receipt = Workflow::activity(SendReceipt::class, $orderId, $label, $approval);
404+
405+
return [
406+
'receipt' => $receipt,
407+
'workflow_id' => $this->workflowId(),
408+
];
409+
}
410+
}
411+
```
412+
413+
`workflowId()` is the stable public instance id for signals, updates, queries,
414+
and message streams. `runId()` is useful for diagnostics and selected-run
415+
tooling, but most authoring code should keep external callers on the instance
416+
id.
417+
418+
## More Info for AI
419+
420+
Most human readers can skip the disclosure below. Open it when you need exact
421+
signatures, return contracts, machine-operable notes, or the full PHP API
422+
surface in one place.
423+
424+
## More Info for AI — exact PHP signatures, return contracts, and durable authoring rules
425+
426+
**Base workflow object**
356427

357428
```php
358429
use Workflow\V2\Workflow;
@@ -382,11 +453,7 @@ abstract class Workflow
382453
| `historySize()` | The workflow needs a byte-based history budget signal. | Approximate persisted history size in bytes. |
383454
| `shouldContinueAsNew()` | The workflow should rotate before history becomes expensive. | `true` when configured history budgets recommend rotation. |
384455

385-
`workflowId()` is the public address for signals, updates, queries, and message
386-
streams. `runId()` is useful for diagnostics and selected-run tooling, but most
387-
authoring code should keep external callers on the instance id.
388-
389-
## Durable Commands
456+
**Durable commands**
390457

391458
The static facade delegates to namespaced helpers in `Workflow\V2`. The two
392459
forms are equivalent:
@@ -423,32 +490,7 @@ $resultFromHelper = activity(SendReceipt::class, $orderId);
423490
| `Workflow::upsertSearchAttributes()` | `upsertSearchAttributes()` | `upsertSearchAttributes(array $attributes): void` | Updates indexed operator-visible metadata. |
424491
| `Workflow::now()` | `now()` | `now(): CarbonInterface` | Reads deterministic workflow time. |
425492

426-
```php
427-
use Workflow\V2\Workflow;
428-
429-
final class FulfillmentWorkflow extends Workflow
430-
{
431-
public function handle(string $orderId): array
432-
{
433-
Workflow::upsertSearchAttributes([
434-
'order_id' => $orderId,
435-
'status' => 'packing',
436-
]);
437-
438-
$label = Workflow::activity(CreateShippingLabel::class, $orderId);
439-
Workflow::timer('15 minutes');
440-
$receipt = Workflow::activity(SendReceipt::class, $orderId, $label);
441-
442-
return [
443-
'receipt' => $receipt,
444-
'workflow_id' => $this->workflowId(),
445-
'run_id' => $this->runId(),
446-
];
447-
}
448-
}
449-
```
450-
451-
## Timer Helpers
493+
**Timer helpers**
452494

453495
Timer helpers are shorthand for `timer()` and `Workflow::timer()`:
454496

@@ -478,7 +520,7 @@ Use explicit `timer()` calls when the duration comes from configuration or
478520
workflow input. Use timer helpers when the source code should read as a fixed
479521
business wait.
480522

481-
## Message Streams
523+
**Message streams**
482524

483525
Open durable message streams from the workflow instance:
484526

@@ -531,7 +573,7 @@ Use message streams for repeated ordered messages with cursor semantics. Use
531573
[Signals](../features/signals.md) for one-shot external events and
532574
[Updates](../features/updates.md) for request/return mutations.
533575

534-
## Attributes And Contracts
576+
**Attributes and public contracts**
535577

536578
```php
537579
use Workflow\QueryMethod;
@@ -577,7 +619,7 @@ final class OrderApprovalWorkflow extends Workflow
577619
Signals, queries, and updates are public workflow contracts. Prefer explicit
578620
names so PHP method renames do not become API breaks.
579621

580-
## Failure Surface
622+
**Failure surface**
581623

582624
Authoring API failures are durable workflow failures unless the command is
583625
rejected before execution:
@@ -597,7 +639,7 @@ For payload and history limits, see [Structural Limits](../constraints/structura
597639
For command rejection responses outside PHP workflow code, see
598640
[Server API Reference](../polyglot/server-api-reference.md).
599641

600-
## Determinism Rules
642+
**Determinism rules**
601643

602644
Workflow code must be replay-safe. Keep irreversible or non-deterministic work
603645
behind durable commands:
@@ -9627,8 +9669,7 @@ and upgrades only when you change the pin.
96279669
Both installer scripts download `SHA256SUMS` from the release and verify the
96289670
asset checksum before replacing `dw`, so a tampered mirror fails the install.
96299671

9630-
<details>
9631-
<summary><b>Linux and macOS</b> (shell installer)</summary>
9672+
## Linux and macOS (shell installer)
96329673

96339674
```bash
96349675
VERSION=0.1.2 curl -fsSL https://durable-workflow.com/install.sh | sh
@@ -9652,10 +9693,7 @@ A GitHub Actions example:
96529693
run: dw --version
96539694
```
96549695

9655-
</details>
9656-
9657-
<details>
9658-
<summary><b>Windows</b> (PowerShell installer)</summary>
9696+
## Windows (PowerShell installer)
96599697

96609698
```powershell
96619699
$env:VERSION = "0.1.2"
@@ -9666,10 +9704,7 @@ dw --version
96669704
The installer writes `dw.exe` to `%USERPROFILE%\.durable-workflow\bin` and adds
96679705
that directory to the user `PATH`.
96689706

9669-
</details>
9670-
9671-
<details>
9672-
<summary><b>PHAR</b> (portable, requires PHP 8.2+)</summary>
9707+
## PHAR (portable, requires PHP 8.2+)
96739708

96749709
```bash
96759710
VERSION=0.1.2
@@ -9685,8 +9720,6 @@ chmod +x dw.phar
96859720
The PHAR works wherever PHP 8.2 or newer is already available and is the
96869721
recommended artifact for shared CI runners that already ship PHP.
96879722

9688-
</details>
9689-
96909723
## Configure
96919724

96929725
Point the CLI at your server:

404.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414

1515
<link rel="search" type="application/opensearchdescription+xml" title="Durable Workflow" href="/opensearch.xml"><link rel="stylesheet" href="/assets/css/styles.bdb910b5.css">
16-
<link rel="preload" href="/assets/js/runtime~main.235fca67.js" as="script">
17-
<link rel="preload" href="/assets/js/main.52e204c2.js" as="script">
16+
<link rel="preload" href="/assets/js/runtime~main.4ca35a9d.js" as="script">
17+
<link rel="preload" href="/assets/js/main.342b76bb.js" as="script">
1818
</head>
1919
<body class="navigation-with-keyboard">
2020
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"dark")}()</script><div id="__docusaurus">
2121
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#docusaurus_skipToContent_fallback">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/logo.svg" alt="Workflow Logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/logo.svg" alt="Workflow Logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Durable Workflow</b></a><a class="navbar__item navbar__link" href="/docs/installation/">Docs</a><div class="navbar__item dropdown dropdown--hoverable"><a class="navbar__link" aria-haspopup="true" aria-expanded="false" role="button" href="/docs/introduction/">1.x</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/2.0/introduction/">2.0</a></li><li><a class="dropdown__link" href="/docs/introduction/">1.x</a></li></ul></div><a class="navbar__item navbar__link" href="/blog/">Blog</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/durable-workflow/workflow" target="_blank" rel="noopener noreferrer" aria-label="Star Durable Workflow on GitHub" class="navbar-github-star-link navbar__item navbar__link" label="Star on GitHub"><svg aria-hidden="true" class="navbar-github-star-link__icon" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8a8.01 8.01 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.5-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.56 7.56 0 0 1 8 4.76c.68 0 1.36.09 2 .27 1.53-1.03 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"></path></svg><span class="navbar-github-star-link__count" title="GitHub stars">1.2K</span></a><a href="https://github.com/durable-workflow/workflow" target="_blank" rel="noopener noreferrer" aria-label="Star Durable Workflow on GitHub" class="navbar-github-star-link navbar__link navbar-github-star-link--mobile-topbar" label="Star on GitHub"><svg aria-hidden="true" class="navbar-github-star-link__icon" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8a8.01 8.01 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.5-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.56 7.56 0 0 1 8 4.76c.68 0 1.36.09 2 .27 1.53-1.03 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"></path></svg><span class="navbar-github-star-link__count" title="GitHub stars">1.2K</span></a><div class="toggle_vylO colorModeToggle_x44X"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type="button" disabled="" title="Switch between dark and light mode (currently dark mode)" aria-label="Switch between dark and light mode (currently dark mode)" aria-live="polite"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_pyhR"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_wfgR"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0"><main class="container margin-vert--xl"><div class="row"><div class="col col--6 col--offset-3"><h1 class="hero__title">Page Not Found</h1><p>We could not find what you were looking for.</p><p>Please contact the owner of the site that linked you to the original URL and let them know their link is broken.</p></div></div></main></div><div><footer class="footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/docs/introduction/">Introduction</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/installation/">Installation</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://discord.gg/xu5aDDpqVy" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://x.com/DurableWorkflow" target="_blank" rel="noopener noreferrer" class="footer__link-item">X<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://durable-workflow.com/llms-full.txt" target="_blank" rel="noopener noreferrer" class="footer__link-item">LLM Docs<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://packagist.org/packages/durable-workflow/workflow" target="_blank" rel="noopener noreferrer" class="footer__link-item">Packagist<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2026 <a href="https://durable-workflow.com">Durable Workflow</a>.</div></div></div></footer></div></div>
22-
<script src="/assets/js/runtime~main.235fca67.js"></script>
23-
<script src="/assets/js/main.52e204c2.js"></script>
22+
<script src="/assets/js/runtime~main.4ca35a9d.js"></script>
23+
<script src="/assets/js/main.342b76bb.js"></script>
2424
</body>
2525
</html>

0 commit comments

Comments
 (0)