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
Flow Control

Flow Control Laravel Package

devhelp/flow-control

Laravel/PHP utilities for controlling application flow: helpers and patterns for branching, conditional execution, retries, and early exits. Designed to simplify complex control logic and keep code paths readable and consistent across projects.

View on GitHub
Deep Wiki
Context7

Flow Control is a simple tool that allows to control the flow defined in the Flow class.

Frequently asked questions about Flow Control
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'))`.
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor