Complex Business Processes
How to manage complex multi-step business workflows in PHP with Ecotone
The Problem You Recognize
Your order fulfillment process spans 6 steps across 4 services. The subscription lifecycle involves payment processing, provisioning, notifications, and grace periods. User onboarding triggers a welcome email, account setup, and a follow-up sequence.
The logic for these processes is spread across:
Event listeners that trigger other event listeners
Cron jobs that check status flags
Database columns like
is_processed,retry_count,step_completed_at
Nobody can explain the full flow without reading all the code. Adding a step means editing multiple files. Reordering steps is risky. When something fails mid-process, recovery means manually updating database flags.
What the Industry Calls It
Two distinct patterns solve this, and they're often confused:
Workflows — stateless pipe-and-filter chaining. The message flows from one handler to the next via output channels. Each step is independent; nothing is remembered across steps.
Sagas — stateful long-running coordination. The saga remembers where it is across events that may arrive seconds, minutes, or days apart, and decides what to do next based on prior state.
Neither Symfony Messenger nor Laravel Queues has a first-class equivalent — both stop at "dispatch a job." Ecotone provides both patterns natively.
How Ecotone Solves It
Workflows — chained handlers. Connect handlers through input and output channels. Each handler does one thing and passes the message on. No coordinator, no state; just declarative flow:
Sagas — stateful coordination. Track state across events that arrive over time. The saga remembers where it is and reacts to each event based on what came before:
Next Steps
Handler Chaining — Simple linear workflows
Sagas — Stateful workflows that remember
Handling Failures — Recovery and compensation
As You Scale: Ecotone Enterprise adds Orchestrators — declarative workflow automation where you define step sequences in one place, with each step independently testable and reusable. Dynamic step lists adapt to input data without touching step code.
Last updated
Was this helpful?