szana8/laraflow
LaraFlow is a Laravel package for adding workflows and state machines to Eloquent models. Define states, transitions, guards, and actions, then move records through controlled paths with events and validation for cleaner approval and status management.
approved?"), cycle-time measurement, and stuck-record detection (records parked in a state past an SLA).canCancel, canRefund), so the UI stops re-deriving permissions from status strings in JavaScript.Consider it when:
status enum plus a pile of if statements and scattered $model->status = ... writes.shipped, webhook on approved) and prefer Laravel events over an internal callback registry.Look elsewhere when:
where status = 'expected' or lockForUpdate) yourself, and you should confirm that before committing.Migration/compliance caveat: for regulated flows (payments, KYC), verify that events alone give you a durable audit log. Events are fire-and-forget unless you persist them; you likely still need a state_transitions history table.
To executives — one paragraph: LaraFlow is a small, MIT-licensed library that makes "where can this record go next?" an explicit, enforced rule in our Laravel codebase instead of an unwritten convention spread across the app. The business value is fewer status-related production bugs, faster delivery of the approval-style features customers keep asking for, and a built-in event stream that tells us how long records sit in each step. The cost is near zero in licensing and infrastructure; the real cost is that the package is lightly maintained, so we should adopt it behind our own thin interface and treat it as code we own.
To engineering — the honest technical brief:
transitionTo-style API on Eloquent models. Low conceptual overhead, easy code review.StateMachine contract, (b) pinning and vendoring if needed, (c) a spike to confirm Laravel 11/12 compatibility and PHP 8.3 support before we depend on it.status writes remain in that model, and the team can add a state in under an hour.Recommendation: Adopt as a reversible, internally-wrapped dependency for single-record lifecycle flows in Laravel. Do not adopt for payment-critical or distributed workflows until we have the concurrency guard and audit table in place.
How can I help you explore Laravel packages today?