christhompsontldr/laravel-fsm
Robust finite state machine for Laravel with zero-config setup. Define states and transitions with guards, actions, and entry/exit callbacks. Event-driven with comprehensive transition logging, validation, caching, and support for multiple state machines per model column.
approval_status and publication_status for documents).Adopt When:
shipped if payment is confirmed").Look Elsewhere If:
"This package lets us model complex business processes—like order fulfillment or content approvals—as structured workflows, reducing bugs and speeding up development. For example, instead of scattered if-else logic for order statuses, we define rules once (e.g., 'paid' → 'shipped' only if payment is verified) and let the system enforce them. It also adds automatic audit logs for compliance, cutting manual tracking work by 50%. We’re using it first for [high-impact feature], with a roadmap to roll it out across [other critical areas]."
ROI:
*"This is a batteries-included FSM for Laravel that handles:
draft → published without review).approval_status + publication_status).TransitionAttempted/TransitionFailed for observability.Why not build it?
Example Use Case:
// Replace this:
if ($order->status === 'paid' && $order->payment_verified) {
$order->status = 'shipped';
$order->save();
SendShippingLabel::dispatch($order);
}
// With this:
$order->fsm()->trigger('ship'); // Handles validation, actions, and events automatically.
```"
**Migration Path**:
1. **Pilot**: Use for a non-critical workflow (e.g., user verification).
2. **Expand**: Roll out to high-risk areas (e.g., payment processing).
3. **Standardize**: Enforce FSM for all new stateful models.
How can I help you explore Laravel packages today?