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 Engine Core Laravel Package

solution-forest/workflow-engine-core

Framework-agnostic workflow engine core for PHP 8.3+. Define and run workflows with type-safe steps, state tracking/persistence, plugins for actions/storage, retries, timeouts, and rich error handling. Actively developed; not production-ready.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strengths:

    • Framework-agnostic design: Aligns perfectly with Laravel’s modularity, allowing seamless integration without framework coupling.
    • State machine rigor: The explicit WorkflowState transitions (e.g., PENDING → RUNNING → COMPLETED) map cleanly to Laravel’s event-driven architecture (e.g., ModelObserver lifecycle hooks).
    • Extensibility: Plugin architecture for actions/storage adapters enables customization (e.g., integrating with Laravel’s Queue system or Cache for persistence).
    • Type safety: PHP 8.3+ generics and strict typing reduce runtime errors, complementing Laravel’s Strict mode.
    • Event system: Rich event dispatching (WorkflowStartedEvent, StepFailedEvent) integrates naturally with Laravel’s Event facade or Broadcasting.
  • Challenges:

    • Laravel-specific dependencies: Current use of data_get()/data_set() (Laravel helpers) violates framework-agnostic claims. Must replace with Arr::get() or similar.
    • Missing Laravel integrations: No built-in support for Laravel’s Queue, Cache, or Database systems (e.g., DatabaseStorageAdapter would require custom implementation).
    • Timeout enforcement: Critical production feature is unimplemented (see Known Issues).
    • Retry logic: Declared but not executed (blocks production use).

Integration Feasibility

  • Laravel Compatibility:
    • High: Core components (e.g., WorkflowEngine, WorkflowBuilder) are framework-agnostic and can be wrapped in Laravel service providers.
    • Low for Laravel-specific features: Requires custom adapters for Laravel’s Queue (for async execution), Cache (for persistence), or Database (for scalable storage).
  • Migration Path:
    • Phase 1: Use SimpleWorkflow for synchronous, in-memory workflows (e.g., CLI commands, admin panels).
    • Phase 2: Implement DatabaseStorageAdapter and QueueExecutor to leverage Laravel’s infrastructure.
    • Phase 3: Replace data_get() with Arr::get() and remove PHPStan suppressions.

Technical Risk

  • Critical Risks:
    • Timeout/Retry Gaps: Unimplemented features could lead to hung workflows or silent failures (e.g., Executor ignores timeout config).
    • Laravel Dependency: data_get() usage will break in non-Laravel environments (already suppressed in PHPStan).
    • State Transition Bugs: Manual state management (e.g., setState()) risks invalid transitions (e.g., RUNNING → PENDING).
  • Mitigation:
    • Short-term: Use SimpleWorkflow for non-critical paths; wrap WorkflowEngine in a Laravel service with fallback logic.
    • Long-term: Contribute fixes for timeout/retry (see Roadmap) or fork the package.

Key Questions

  1. Persistence Strategy:
    • Will workflows require durability (e.g., DatabaseStorageAdapter) or can they be ephemeral (e.g., InMemoryStorage)?
    • Impact: Ephemeral workflows simplify integration but lose resilience.
  2. Async Execution:
    • Should workflows run synchronously (blocking) or asynchronously (queued)?
    • Impact: Async requires QueueExecutor (not implemented); sync limits scalability.
  3. Laravel-Specific Features:
    • Will workflows need to integrate with Laravel’s Queue, Cache, or Database?
    • Impact: Custom adapters will be needed (e.g., QueueStorageAdapter).
  4. Error Handling:
    • How should workflow failures be surfaced (e.g., Laravel’s Exception handler, Slack alerts)?
    • Impact: Event system (WorkflowFailedEvent) can trigger Laravel listeners.
  5. Testing Strategy:
    • Will tests use Laravel’s DatabaseMigrations or the package’s InMemoryStorage?
    • Impact: InMemoryStorage is faster but doesn’t test persistence.

Integration Approach

Stack Fit

  • Laravel Integration Points:

    Component Laravel Equivalent Integration Strategy
    Storage Database, Cache, Redis Implement DatabaseStorageAdapter or CacheStorageAdapter.
    Async Execution Queue Wrap WorkflowEngine in a QueuedWorkflowExecutor.
    Event Dispatching Event facade Dispatch WorkflowStartedEvent → Laravel’s event() method.
    Logging Log facade Replace NullLogger with LaravelLoggerAdapter.
    Configuration .env Bind WorkflowEngine to Laravel’s config() via service provider.
    Testing DatabaseMigrations, Mockery Use InMemoryStorage for unit tests; DatabaseStorageAdapter for integration tests.
  • Recommended Stack:

    • Core: WorkflowEngine + DatabaseStorageAdapter (for durability).
    • Async: Queue + QueuedWorkflowExecutor (for scalability).
    • Events: Laravel’s Event facade (for notifications).
    • Testing: InMemoryStorage (unit) + DatabaseStorageAdapter (integration).

Migration Path

  1. Pilot Phase (1–2 weeks):

    • Replace data_get() with Arr::get() (or data_get() polyfill).
    • Implement DatabaseStorageAdapter for basic persistence.
    • Use SimpleWorkflow for synchronous, non-critical workflows (e.g., admin panels).
    • Goal: Validate core functionality without async or advanced features.
  2. Production-Ready Phase (2–4 weeks):

    • Implement QueuedWorkflowExecutor to offload workflows to Laravel’s Queue.
    • Add RetryMiddleware and TimeoutMiddleware (or contribute fixes to upstream).
    • Integrate with Laravel’s Event system (e.g., WorkflowFailedEvent → Slack alert).
    • Goal: Support async, resilient workflows with observability.
  3. Optimization Phase (Ongoing):

    • Replace InMemoryStorage with CacheStorageAdapter for high-throughput workflows.
    • Add Laravel-specific actions (e.g., NotifyAction using Notification facade).
    • Goal: Leverage Laravel’s ecosystem fully.

Compatibility

  • Pros:
    • No framework dependencies in core (except data_get()).
    • Type safety aligns with Laravel’s Strict mode.
    • Event system maps to Laravel’s Event facade.
  • Cons:
    • Missing Laravel integrations (e.g., Queue, Cache).
    • Unimplemented critical features (timeout, retry).
    • data_get() dependency breaks framework-agnostic claim.

Sequencing

  1. Critical Fixes:
    • Replace data_get() with Arr::get() (blocker for non-Laravel use).
    • Implement TimeoutMiddleware (blocker for production use).
  2. Core Integration:
    • Wrap WorkflowEngine in a Laravel service provider.
    • Implement DatabaseStorageAdapter.
  3. Async Support:
    • Create QueuedWorkflowExecutor for Laravel’s Queue.
  4. Observability:
    • Dispatch Laravel events for workflow lifecycle.
  5. Testing:
    • Add Pest tests using InMemoryStorage (unit) and DatabaseStorageAdapter (integration).

Operational Impact

Maintenance

  • Pros:
    • Framework-agnostic core: Easier to maintain if Laravel dependencies are minimized.
    • Event-driven design: Clear separation of concerns (e.g., actions, storage, events).
    • Type safety: Reduces runtime errors (PHP 8.3+ generics).
  • Cons:
    • Unimplemented features: Timeout/retry require ongoing fixes or forks.
    • Laravel-specific hacks: data_get() replacement and custom adapters add maintenance overhead.
    • Testing gap: Limited test coverage for critical features (e.g., retry logic).

Support

  • Strengths:
    • Rich events: WorkflowFailedEvent can trigger Laravel notifications (e.g., Slack, email).
    • State introspection: WorkflowInstance::getStatusSummary() provides debug info.
    • Plugin architecture: Custom actions/storage adapters can be debugged independently.
  • Challenges:
    • Debugging async workflows: Requires QueuedWorkflowExecutor + Laravel’s Queue monitoring.
    • State transition errors: Invalid transitions (e.g., RUNNING → PENDING) may cause silent failures.
    • Lack of Laravel docs: No official guides for integrating with Laravel’s Queue/Cache.

Scaling

  • Performance:
    • Synchronous: InMemoryStorage is fast but not durable.
    • Asynchronous: QueuedWorkflowExecutor + DatabaseStorageAdapter
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony