Workflow Events
Durable Workflow dispatches events at key points in a workflow’s lifecycle. You can listen to these events to implement custom logging, monitoring, or side effects.WorkflowStarted
Dispatched when a new workflow instance begins execution.Properties
| Property | Type | Description |
|---|---|---|
workflowId | int|string | Unique identifier for the workflow instance |
class | string | Fully qualified class name of the workflow |
arguments | string | Serialized workflow input arguments |
timestamp | string | ISO 8601 timestamp when the workflow started |
Example Usage
Listening in EventServiceProvider
WorkflowCompleted
Dispatched when a workflow successfully completes execution.Properties
| Property | Type | Description |
|---|---|---|
workflowId | int|string | Unique identifier for the workflow instance |
output | string | Serialized workflow output/result |
timestamp | string | ISO 8601 timestamp when the workflow completed |
Example Usage
Listening in EventServiceProvider
WorkflowFailed
Dispatched when a workflow fails due to an unhandled exception or error.Properties
| Property | Type | Description |
|---|---|---|
workflowId | int|string | Unique identifier for the workflow instance |
output | string | Serialized error information or exception details |
timestamp | string | ISO 8601 timestamp when the workflow failed |
Example Usage
Listening in EventServiceProvider
StateChanged
Dispatched when a workflow state transitions from one state to another. This is particularly useful for workflows using the state machine pattern.Properties
| Property | Type | Description |
|---|---|---|
initialState | ?State | The previous state (null if transitioning from no state) |
finalState | ?State | The new state (null if transitioning to no state) |
model | Model | The Eloquent model that owns the state |
field | ?string | The field name on the model that stores the state |
Example Usage
Listening in EventServiceProvider
Global Event Listening
You can listen to all workflow events using a wildcard listener:Event Subscribers
For more complex event handling, create an event subscriber:EventServiceProvider: