symfony/workflow
Symfony Workflow Component helps you model and run workflows or finite state machines in PHP. Define places, transitions, and guards to control state changes, track progress, and integrate with events for process automation.
is_approved, is_shipped) with a single source of truth, reducing technical debt.OrderShipped event when an order transitions from shipped to delivered.ship if order.is_payable() AND user.tier >= 'premium'), replacing manual validation logic.TraceableWorkflow) and event history for compliance (GDPR, SOX) without custom implementation.AppServiceProvider).MethodMarkingStore to persist states to database columns (e.g., order.status).WorkflowTransitionEvent).workflow:dump CLI or Mermaid diagrams (via Profiler) for visualization, without additional dependencies.| Risk Area | Mitigation Strategy |
|---|---|
| PHP Version | Requires PHP 8.2+ (v7.x) or 8.4+ (v8.x). Downgrade to v6.4 for older PHP (but loses features). |
| Learning Curve | Moderate for teams unfamiliar with Symfony. Provide internal docs and workflow examples (e.g., order, content approval). |
| Performance Overhead | ~5–10ms per workflow initialization. Benchmark in staging; negligible for most use cases. |
| State Persistence | Requires manual sync with Eloquent (e.g., MethodMarkingStore). Test edge cases (e.g., concurrent transitions). |
| Event Dispatch | Laravel events must be manually mapped to workflow transitions. Use event listeners for side effects. |
| Debugging | Limited native Laravel debugging. Use Symfony Profiler or custom logging for traces. |
OrderShipped, ContentPublished)v1_order_workflow.yaml) for backward compatibility?Workflow in PHPUnit, test guards/transitions)MethodMarkingStore.WorkflowTransitionEvent → OrderShipped).content.published).assertWorkflowTransitioned() helper).config/workflows/*.yaml.is_approved, status flags).convertLegacyStatusToWorkflow()).| Component | Compatibility Notes |
|---|---|
| Laravel | Framework-agnostic; integrates via service binding and Eloquent. |
| PHP 8.2+ (v7.x) | Supports BackedEnum, strict_types, and modern PHP features. |
| PHP 8.4+ (v8.x) | Adds weighted transitions, explicit interface parameters. |
| Eloquent | Use MethodMarkingStore to sync states to model attributes. |
| Redis/Memcached | Store workflow states in cache for high-performance scenarios. |
| Symfony Profiler | Visualize workflows via Mermaid diagrams (requires Symfony HTTP kernel). |
| Laravel Queues | Offload async side effects (e.g., ContentPublished → send email via queue). |
| Laravel Events | Dispatch custom events on transitions (e.g., WorkflowTransitionEvent). |
symfony/workflow to composer.json.config/workflows/*.yaml.AppServiceProvider.MethodMarkingStore for Eloquent sync.order.is_payable()).Workflow::fromYaml()).php artisan workflow:dump for CLI debugging.How can I help you explore Laravel packages today?