[RFC] A Durable component: durable execution on top of Messenger, with Doctrine and Temporal bridges
Description
This RFC proposes a new experimental component for durable execution, Durable, with two bridges shipped the way Messenger ships its transports: Doctrine DBAL (symfony/doctrine-durable) and Temporal (symfony/temporal-durable). It is opened alongside #65921, which asks whether the framework should provide durable, versioned process managers on top of Messenger. Durable answers the same need with another model, and this RFC puts that model up for discussion on its own terms. The code exists today as gplanchat/durable-dev (docs).
Motivation
Symfony can queue a message (Messenger) and model a state machine (Workflow), but it cannot run a multi-step process that survives a crash, a deploy or a week-long wait. Today, each application hand-writes that layer from Messenger handlers, status columns and retry cron jobs.
Durable execution is the established answer elsewhere: Temporal, AWS Step Functions, Azure Durable Functions. A workflow is plain code. Every side effect runs as an activity, and its result is appended to a journal. After a crash, the workflow replays from the journal instead of running the side effects again.
The PHP options today do not fit a Symfony application:
- The official Temporal PHP SDK (
temporal/sdk) requires RoadRunner as its worker. The workflow code runs outside the Symfony kernel lifecycle, and the application needs a second runtime. - Hand-rolled Messenger sagas have no replay. The state lives in ad-hoc tables, and each team rediscovers idempotency, timers and compensation.
Durable runs workflows with PHP Fibers inside a regular Symfony worker, over Messenger transports. The same workflow class runs on three backends: in-memory for tests, a single SQL database through Doctrine DBAL, or a Temporal cluster. Switching between the last two is an operations choice, not a code change.
Agentic applications make the need concrete: a multi-step LLM agent that waits for a human approval is a durable workflow. The Symfony AI v1.0 roadmap (symfony/ai#1301) lists state handling in the Agent as a must, and integration with Messenger and Workflow as a should.
Relation to #65921 and Messenger's building blocks
Durable is durable execution, where the process is code replayed from a journal, rather than a process manager, where a state object reacts to events.
| #65921 asks for | A process manager (Ecotone Sagas, Lendable's) | Durable |
|---|---|---|
| Persisted state, optimistic locking | a state object per instance, locked on update | no state object: the journal is the state, replayed on resume; one resume at a time per execution |
| Correlating incoming messages | a correlation key read from a stamp or the message | signals, updates and queries addressed to an execution id |
| Timeouts | messages scheduled through the Scheduler | timers recorded in the journal: $env->sleep(), $env->timer(), a deadline on any await() |
| Versioning | a revision on the definition; running instances finish on theirs | declared change points ($env->version()), and a guard that stops a replay from diverging from its history |
| Audit history | recorded next to the state | the journal itself: every activity result, signal and timer |
| Waiting for several events | one handler per event, updating the state | $env->all(), any(), some() or await(fn () => ...), in plain code |
Durable does not need the prerequisites #65921 lists (message identity #65899, the inbox #65918, the Scheduler). Its journal records each activity result once, so a redelivered resume replays instead of running the activity again. The one known gap, an attempt that failed and was retried, is tracked in gplanchat/durable-dev#319. Durable uses Messenger as its transport only.
The two models fit different processes. A process manager suits event-driven integration, where the process reacts to other systems and its state is a business entity worth querying. Durable execution suits orchestration, where the process drives the steps, calls services, and reads best as code. They can coexist.
Simple flows need neither. ChainStamp (#65903) and DispatchOnFailureStamp (#65917) chain messages with a failure hook, and the outbox (#65901) makes a dispatch atomic with the database. Durable targets processes that wait, branch, and survive deploys.
Proposal
Three packages mirror the Messenger layout, where symfony/messenger ships its transports as Bridge/Amqp, Bridge/Doctrine and Bridge/Redis.
| Today | Proposed package | Path in symfony/symfony |
Size today |
|---|---|---|---|
gplanchat/durable |
symfony/durable |
src/Symfony/Component/Durable/ |
17,002 lines |
gplanchat/durable-bridge-dbal |
symfony/doctrine-durable |
src/Symfony/Component/Durable/Bridge/Doctrine/ |
734 lines |
gplanchat/durable-bridge-temporal |
symfony/temporal-durable |
src/Symfony/Component/Durable/Bridge/Temporal/ |
7,466 hand-written lines, plus generated code (see below) |
gplanchat/durable-bundle |
none, folded into FrameworkBundle | framework.durable configuration, a WebProfilerBundle panel |
4,215 lines |
Sizes are the lines of the package's .php files at the v0.1.0-alpha13 tag, blank lines and comments included; for the Temporal bridge, without the generated Api/ and Generated/ directories.
What changes on the way in:
- Namespace:
Gplanchat\Durable\becomesSymfony\Component\Durable\. The project already ships Rector rules for its own BC breaks, and would ship one for this rename. - The bundle disappears. Its configuration tree becomes
framework.durable, its compiler passes move to FrameworkBundle, and its data collector moves to WebProfilerBundle. Thedurable:diagnosecommand moves into the component, as Messenger's commands live inSymfony\Component\Messenger\Command. - Version ranges collapse. The packages accept Symfony
^6.4 || ^7.0 || ^8.0and PHP>=8.2today. In the monorepo they follow the branch they land on. - Experimental. The component and both bridges land as
@experimental, outside the BC promise, for at least one minor version.
Out of scope, staying third-party on top of the component: the Laravel integration, the Magento module, the Sylius plugin, the PHPStan and Rector extensions, and the dashboard plugin.
Workflow method arguments are resolved like a controller's. The workflow method receives its activity stubs and its WorkflowEnvironment as arguments. #[Activities(Contract::class)] names the stub's contract; reading it is plain reflection, following the #[MapEntity] and #[Autowire] idiom. The @param ActivityStub<Contract> docblock is optional and serves PHPStan; a rule in the PHPStan extension reports a docblock that disagrees with the attribute. Injected parameters are not part of the workflow's input, which stays keyed by name. Mistakes fail when the workflow is registered, that is when the container compiles. Constructor injection of the environment keeps working. This shipped in gplanchat/durable-dev#423.
The attribute also carries the stub's activity options. This shipped in gplanchat/durable-dev#463. Before it, an injected stub ran with the default options: unlimited attempts and no timeout, which on Temporal meant a 30 s fallback per attempt. A long or heartbeating activity then needed $env->activityStub($contract, $options) in the body. #[Activities] now takes optional named arguments that mirror ActivityOptions::of(). They are scalars, arrays of class names and enum cases, so they are valid in an attribute:
#[Activities(
PaymentActivities::class,
attempts: 3,
startToClose: 120.0, // seconds, one attempt
scheduleToClose: 600.0, // seconds, retries included
heartbeat: 10.0,
nonRetryable: [CardDeclined::class],
taskQueue: 'payments',
)]
ActivityStub $payments,The options are built once, when the workflow is registered, so a bad value (zero attempts, a negative duration, a heartbeat longer than startToClose, a non-retryable entry that is not a Throwable, a backoff coefficient below 1, a maximum interval shorter than the first retry delay) fails when the container compiles, and the message names the parameter. The activity ID stays out, since it belongs to one call, not to the stub. Without options, nothing changes.
The Temporal bridge
The Temporal bridge belongs in the monorepo for the same reason the AMQP bridge does: both are Messenger transports to an external broker. Unlike symfony/amqp-messenger, which requires ext-amqp, the Temporal bridge only suggests ext-grpc and ext-curl. Without the gRPC extension it speaks the same protocol over curl and HTTP/2.
It talks to the Temporal frontend directly, without temporal/sdk and without RoadRunner. The DSN picks the wire:
| DSN | Wire | Requires | Covers |
|---|---|---|---|
temporal://, temporal+tls:// |
gRPC through ext-grpc, when loaded |
ext-grpc |
everything |
same, without the extension (or transport=grpc-curl) |
the same gRPC protocol through curl over HTTP/2 | ext-curl with HTTP/2 |
everything, workers included |
temporal+http://, temporal+https:// |
the server's JSON gateway | ext-curl |
the client side only: start, signal, query, update, describe, history, cancel |
One Temporal server means one DSN, set once under framework.durable.temporal.dsn. The integration registers the workers itself, as Messenger receivers named durable_workflows, durable_activities and durable_nexus, with no transport entry in messenger.yaml.
Three things differ from AMQP:
- Generated code. The bridge embeds the protobuf classes generated from Temporal's API definitions: about 5.4 MB, autoloaded in the
Temporal\Api\namespace.roadrunner-php/roadrunner-api-dto, whichtemporal/sdkrequires, ships the same namespace, so the two cannot be installed together. Symfony cannot ship code in a third-party namespace, so these classes must leave the monorepo. The options are: requireroadrunner-php/roadrunner-api-dto, publish the stubs as a separate package under a non-colliding namespace, or ask Temporal for an official, SDK-free stubs package. - HTTP/2 trailers. The curl wire cannot use HttpClient yet: gRPC puts the call status in the trailers, and HttpClient discards them. #66256, opened for #66250, exposes them as a
trailersresponse info. Once it ships, the curl wire can move onto HttpClient. - Protocol ownership. Without the official SDK, keeping up with Temporal server releases (history event parity, the update protocol, Nexus) is the bridge's job, and would become Symfony's maintenance burden.
Symfony's CI would also need a Temporal dev server as a service, as it runs RabbitMQ and Redis for Messenger.
Other backends
The backend seam is the one the Temporal bridge already uses: a history source, a command buffer and a lifecycle, driven by the same Fiber driver. That leaves room for more bridges without touching the component. A spike for a third one, Restate, runs a PHP endpoint against restate-server 1.7.12 through its request-response protocol, with a hand-written codec and no SDK, gRPC or long-running worker (gplanchat/durable-dev#464, gplanchat/durable-dev#466). Durable's execution loop is not wired to it yet. Two caveats:
- Queries have no counterpart there, because Restate has no read-only replay that we found.
- The Restate server is under the Business Source License 1.1, where Temporal is MIT; the protocol specification is MIT.
This RFC does not propose a Restate bridge.
The worker process
The packages ship a dedicated command, durable:worker [--role=workflow|activity|nexus|all] (gplanchat/durable-dev#436, for gplanchat/durable-dev#338). It runs Messenger's worker over Durable's receivers (durable_workflows, durable_activities, durable_nexus), which messenger:consume still accepts by name. It resolves the receiver names from Durable's configuration, prints them, refuses to start when nothing consumes workflow resumes, and delegates to messenger:consume, forwarding its stop signals. On Temporal, --limit and --failure-limit never stop the worker, because the receivers answer their task inside get() and hand no message to Messenger; --time-limit and --memory-limit do, once the current long poll returns. Each receiver long-polls and one worker polls its receivers in turn, so one process per role is the recommended setup there. Magento already ships bin/magento durable:worker, and Laravel ships durable:temporal-worker.
Open for the component: should durable:worker be the documented entry point, with messenger:consume as an escape hatch? Or should Durable's receivers stay ordinary Messenger receivers, mixed with the application's transports? And if the dedicated command wins, should receivers that work inside get() stop being exposed as transports, so that retry_strategy and failure_transport cannot be configured on them to no effect?
Maturity
The code is young and not ready to merge. This RFC asks whether the direction is welcome, so the remaining work can aim at Symfony's conventions from now on.
| 2026-09-24 | |
|---|---|
| First commit | 2026-03-24 |
| Latest release | v0.1.0-alpha13 |
| Maintainers | 1 |
| Test methods | 898 |
| Psalm baseline | 0 entries |
Open issues before 0.1.0-beta1 |
14 (milestone) |
Test methods are the function test* declarations under tests/ at the same tag, unit and integration suites together.
Before a pull request, I would want these to hold:
- the replay and durability guarantees measured in CI;
- the Temporal integration tests running in CI;
- HTTP trailers exposed by HttpClient (#66250), so the Temporal curl wire runs on HttpClient;
- SQL conformance on MySQL and PostgreSQL;
- a public API unchanged across two releases;
- production users beyond my own projects;
- a second maintainer.
Alternatives considered
| Alternative | Why not, or not only |
|---|---|
| Stay a third-party package set | Works today and remains the fallback. Durable execution is infrastructure that other components could rely on, like Messenger and Lock. |
| A process manager on top of Messenger (#65921) | Fits event-driven processes whose state is a business entity. Durable fits processes that drive their steps and read best as code. The two can coexist. |
ChainStamp and DispatchOnFailureStamp (#65903, #65917) |
Enough for a fixed sequence of messages with a failure hook. No waiting on events, no branching on results, no timers. |
| Extend the Workflow component | Workflow models the states of an object. It has no journal, replay, timers or activities, and adding them would change what it is. |
| Core in the monorepo, Temporal bridge outside | Smaller review surface, but it breaks the Messenger precedent, and it would leave the one distributed backend without Symfony's CI. |
A bridge on temporal/sdk |
Brings RoadRunner into the worker model, which is what Durable avoids. |
Naming
"Workflow" means three things around this proposal, and only one of them is Durable's:
| Word | Symfony today | Temporal | Durable today |
|---|---|---|---|
| Workflow | the Workflow component: the states and transitions of one object | a durable function, replayed from its history | the same as Temporal: #[AsWorkflow], WorkflowEnvironment, the durable_workflows receiver, --role=workflow |
| Saga | nothing | a helper class that stacks compensations and runs them in reverse | the same idea: Saga stacks compensations and runs them in reverse (gplanchat/durable-dev#440) |
| Process manager | nothing (#65921 asks) | nothing | nothing |
A component that says "workflow" next to symfony/workflow would be read as an extension of it, which it is not. The proposal is to rename Durable's workflow to Saga in the component's public vocabulary: #[AsSaga], #[AsSagaMethod], SagaEnvironment, a durable_sagas receiver, --role=saga. On the wire nothing changes. Temporal still calls it a workflow, the workflow types and task queues keep their names, and the Temporal bridge keeps Temporal's words where it speaks Temporal.
A saga, in Garcia-Molina and Salem's sense, is a long-lived process made of steps, each with a compensation. That is what a Durable workflow is used for, and it is how the PHP ecosystem already names such processes (Ecotone's Sagas, #65921). The catch is that Durable now ships a compensation helper under Temporal's name: Saga (gplanchat/durable-dev#440, used in the saga example below), a stack of compensating calls run in reverse on failure or cancellation. If the workflow becomes a Saga, that helper would be renamed Compensation, so that "Saga" names one thing only.
Open questions
- Is a durable execution component in scope for
symfony/symfony, and on which branch could an experimental version land? - Is durable execution an acceptable answer to #65921, or should the framework ship a process manager first, with Durable staying a third-party layer?
- The component's name: "Durable" sits next to "Workflow". Would another name read better in the component list?
- Naming (see above): should "workflow" be renamed to "Saga" in the component's public API, keeping Temporal's "workflow" on the wire only? Would "Saga" collide with the process managers #65921 describes, which Ecotone also calls sagas, or unify the two vocabularies? And if so, is
Compensationthe right new name for today'sSagahelper, which is what Temporal calls it? - Where should the generated Temporal API classes live?
- The worker process model (see above).
- Serialization: Durable uses the Serializer component where available. Should the component require it, or keep it optional as Messenger does?
Example
The same code runs unchanged on the in-memory, Doctrine DBAL and Temporal backends.
A saga with compensation
#[AsWorkflow(name: 'place-order')]
final class PlaceOrderWorkflow
{
/**
* @param ActivityStub<InventoryActivities> $inventory
* @param ActivityStub<PaymentActivities> $payments
* @param ActivityStub<ShippingActivities> $shipping
*/
#[AsWorkflowMethod]
public function run(
string $orderId,
#[Activities(InventoryActivities::class)]
ActivityStub $inventory,
#[Activities(PaymentActivities::class, attempts: 3, startToClose: 30.0)]
ActivityStub $payments,
#[Activities(ShippingActivities::class)]
ActivityStub $shipping,
WorkflowEnvironment $env,
): string {
$saga = new Saga();
try {
$reservation = $env->await($inventory->reserve($orderId));
$saga->addCompensation(fn () => $env->await($inventory->release($reservation)));
$charge = $env->await($payments->charge($orderId));
$saga->addCompensation(fn () => $env->await($payments->refund($charge)));
return $env->await($shipping->ship($orderId, $reservation));
} catch (DurableActivityFailedException|WorkflowCancelledFailure $e) {
$saga->compensate();
throw $e;
}
}
}Each result is journaled. If the worker dies between the charge and the shipment, the next worker replays reserve() and charge() from the journal and resumes at ship(): the card is charged once. A cancellation requested from outside is raised at the pending await(), so the same compensation path runs. Saga runs the compensations in reverse order; each one calls await() itself, so it finishes before the next starts (gplanchat/durable-dev#440). The charge gets three attempts of at most 30 s each before the compensations run.
Human approval: a signal, a deadline, a query
#[ASource: symfony/symfony