Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Workflow Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Unified State Management: Replace scattered boolean flags (e.g., is_approved, is_processed) with a centralized workflow system, reducing technical debt and improving maintainability. Ideal for complex domains like order processing, content moderation, or HR pipelines.
  • Compliance & Auditability: Enforce immutable state transitions with timestamps and event traces, critical for GDPR, SOX, or financial workflows. Integrates seamlessly with Laravel’s logging for full audit trails.
  • Feature Rollouts & A/B Testing: Implement progressive feature rollouts (e.g., "beta → public") with guard conditions (e.g., user.tier >= 'premium'), replacing manual flag checks and enabling data-driven decisions.
  • Build vs. Buy Decision: Avoid 3–6 months of custom state machine development while supporting future scalability (e.g., weighted transitions, BackedEnum). Symfony’s Workflow is battle-tested (used by Sentry, Shopware) and aligns with Laravel’s ecosystem.
  • Multi-Tenant Workflows: Define tenant-specific workflows (e.g., different approval chains per client) via dynamic configuration, reducing per-tenant customization costs and improving scalability.
  • Event-Driven Architecture: Decouple workflows from business logic by triggering Laravel events (e.g., OrderShipped) for notifications, analytics, or async tasks (via Laravel Queues). Supports real-time integrations with third-party services.
  • Roadmap Flexibility: Future-proof the system with weighted transitions, custom validators, and Mermaid visualization, ensuring long-term adaptability without major refactors.

When to Consider This Package

Adopt when:

  • Workflows require >3 states with conditional transitions (e.g., "approve if verified AND budget > $X").
  • You need event-driven side effects (e.g., send email on order.shipped, log to audit table).
  • Visualization is critical (Mermaid diagrams via Symfony Profiler or workflow:dump CLI).
  • Supporting PHP 8.2+ (v7.x) or 8.4+ (v8.x) and willing to integrate Symfony components.
  • Team has moderate Symfony/Laravel experience or can dedicate 1–2 dev days to integration.
  • Workflows must scale across microservices (e.g., shared workflow definitions via API).
  • Audit trails and compliance are non-negotiable (e.g., financial, healthcare, or legal domains).

Avoid when:

  • State logic is static and simple (e.g., is_active toggle → use Eloquent accessors or spatie/laravel-state-machine).
  • Running PHP < 8.2 (v7.x) or < 8.4 (v8.x) without downgrading.
  • Workflows are graph-based (e.g., pathfinding) or require parallel execution (use Laravel Tasks or Symfony Messenger instead).
  • Prefer Laravel-native solutions for trivial cases (e.g., spatie/laravel-state-machine for 2-state processes).
  • High-performance constraints exist (workflow initialization adds ~5–10ms overhead per request; negligible for most apps but critical for ultra-low-latency systems).
  • The team lacks Symfony/Laravel familiarity and cannot allocate time for integration.

How to Pitch It (Stakeholders)

Executives: *"Symfony Workflow is a proven, enterprise-grade solution for managing complex business processes—like order fulfillment, content approvals, or user onboarding—with zero manual errors and full auditability. Here’s why it’s a game-changer for us:

  • Eliminates Technical Debt: Replace 100+ lines of spaghetti if-else logic with declarative workflows (e.g., cart → checkout → shipped → delivered). Used by Sentry, Shopware, and Blackfire to streamline critical processes.
  • Compliance-Ready: Enforce immutable state transitions with timestamps, ensuring GDPR/SOX compliance. Every change is logged and traceable.
  • Faster Time-to-Market: Add new workflows (e.g., refunds, cancellations) without refactoring existing code. Save 3–6 months of development time vs. building a custom solution.
  • Scalable & Future-Proof: Supports multi-tenant workflows, weighted transitions, and event-driven integrations—all while being framework-agnostic (no Laravel lock-in).
  • Minimal Integration: Just add the package and define workflows in YAML. No framework lock-in, and it works alongside Laravel’s ecosystem. For example: If we adopt this for our e-commerce platform, we could reduce order processing errors by 70% and cut support costs by automating approval chains.*

Engineering (Devs): *"Symfony Workflow is a powerful, flexible finite state machine for PHP. Here’s how it fits into Laravel and why it’s worth adopting:

Key Features

  1. Declarative Workflows: Define states and transitions in YAML or PHP (version-controlled, diffable).
    # config/workflows/order.yaml
    support:
      places: [cart, checkout, shipped, delivered, cancelled]
      transitions:
        checkout: { from: cart, to: checkout }
        ship: { from: checkout, to: shipped, guard: 'order.is_payable()' }
    
  2. Event-Driven: Trigger Laravel events on transitions (e.g., OrderShipped) for:
    • Notifications (via Laravel Notifications).
    • Analytics (log to databases or third-party tools).
    • Async tasks (via Laravel Queues).
  3. Audit Trails: Use TraceableWorkflow to log every transition with timestamps, enabling compliance and debugging.
  4. Laravel Integration:
    • Register workflows in AppServiceProvider:
      $this->app->bind('order_workflow', fn() => new Workflow(new YamlFileLoader(__DIR__.'/workflows/order.yaml')));
      
    • Sync states with Eloquent via MethodMarkingStore:
      $store = new MethodMarkingStore($order, 'status');
      $workflow->apply($store, 'ship'); // Updates $order->status = 'shipped'
      
  5. Visualization: Generate Mermaid diagrams for workflows using Symfony Profiler or the workflow:dump CLI command.

Tradeoffs

  • PHP Version: Requires 8.2+ (v7.x) or 8.4+ (v8.x). Downgrades are possible but not recommended.
  • Overhead: ~5–10ms per workflow (negligible for most apps; benchmark in your environment).
  • Learning Curve: Moderate (1–2 dev days to integrate). Symfony’s docs are excellent, and the Laravel community has examples.

Alternatives

  • For simple 2-state processes: Use spatie/laravel-state-machine (Laravel-native, lighter).
  • For graph-based workflows: Consider Symfony Messenger or custom solutions.
  • For PHP < 8.2: Stick with Eloquent accessors or manual state flags.

Next Steps

  1. Prototype: Test with a non-critical workflow (e.g., user onboarding).
  2. Benchmark: Measure overhead in your environment.
  3. Integrate: Define workflows in YAML and sync with Eloquent.
  4. Scale: Roll out to order processing, content moderation, or approval pipelines.

Let’s start with a pilot—this could save us hundreds of dev hours and reduce bugs long-term."*

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation