- What Laravel versions does devhelp/flow-control support?
- The package requires PHP 8.0+ and is designed for Laravel 10/11. Check the `composer.json` for exact version constraints, as the README doesn’t specify. Always verify compatibility with your Laravel version before installing.
- How do I define a multi-step workflow in Flow Control?
- Use the `Flow` class with an associative array where keys are step names and values are arrays of allowed next steps. Specify entry points in the third parameter. Example: `new Flow('checkout', ['cart' => ['payment'], 'payment' => ['confirm']], ['cart'])`.
- Can Flow Control handle asynchronous workflows (e.g., queues or jobs)?
- No, this package is synchronous and designed for in-memory workflows. For async workflows, consider Laravel Jobs, Tasks, or a state machine like `spatie/laravel-state-machine` with queue support.
- How do I validate if a step transition is allowed in my workflow?
- Use `FlowControl::isAllowed($nextStep, $flowName)`. It checks if `$nextStep` is a valid successor of the current step. Example: `$flowControl->isAllowed('confirm', 'checkout')` returns `true` if `confirm` follows the current step.
- Does Flow Control integrate with Laravel’s service container?
- No direct integration is documented. You’ll need to manually bind the `FlowControl` and `SimpleFlowRepository` classes in your `AppServiceProvider` or use them directly in controllers/services.
- How do I handle errors or failed steps in a workflow?
- The package doesn’t include built-in retry or compensation logic. You’ll need to wrap step logic in try-catch blocks and manually handle failures. For retries, pair it with Laravel’s `retry()` helper or a queue job.
- Can I dynamically load workflows from a database or config file?
- No, workflows must be defined in code at runtime via the `Flow` class. For dynamic workflows, consider extending `SimpleFlowRepository` or using a database-backed state machine like `spatie/laravel-state-machine`.
- What’s the performance impact of complex workflows (e.g., 50+ steps)?
- The package uses in-memory arrays for validation, so performance is O(1) for `isAllowed()` checks. However, resolving valid moves (`resolveValid()`) becomes O(n) for large workflows. Test with your expected scale.
- Are there alternatives to Flow Control for Laravel workflows?
- Yes. For simple branching, consider `spatie/laravel-state-machine` (supports DB persistence). For async workflows, use Laravel Jobs/Tasks. For admin workflows, Laravel Nova Actions may suffice. Evaluate based on your need for sync/async, persistence, and complexity.
- How do I test workflow logic with PHPUnit?
- Mock the `FlowControl` and `SimpleFlowRepository` classes to isolate workflow logic. Test transitions with `isAllowed()` and validate `resolveValid()` outputs. Example: `$this->assertTrue($flowControl->isAllowed('next_step', 'workflow'))`.