Technical Mid Level

What is the Symfony Workflow component and when would you use it? Explain the difference between a workflow and a state machine, and give an example.

Quick Tip

I use a state machine for order status — placed, paid, shipped, delivered. Transitions are guarded: you cannot ship until paid. Guard listeners check business rules. The profiler shows the visual graph of all possible transitions.

What good answers include

The Workflow component models business processes with places (states) and transitions (allowed state changes). A state machine allows only one current place; a workflow allows multiple concurrent places. Configuration lives in config/packages/workflow.yaml. Use cases: order processing (draft to submitted to approved to shipped), content moderation (pending to reviewed to published), and any domain with defined state transitions. Events fire on each transition (guard, enter, leave, completed) allowing you to hook in business logic. Strong candidates explain: using guard events to block transitions based on conditions, storing the state on the entity via a marking_store, and the audit trail feature for compliance.

What interviewers are looking for

Tests whether candidates reach for framework tools versus reinventing state management. Those who use if/else chains for complex state logic create unmaintainable code. The Workflow component provides validation, events, and visual debugging.

← All Symfony questions