A robust, fluent step execution engine for Laravel applications. safely execute a series of steps with optional transaction support, error handling, and rollback capabilities.
- Fluent Interface: Chain steps together easily.
- Transaction Support: Wrap execution in a database transaction with automatic retry on deadlocks.
- Error Handling: Custom exception handlers per step.
- Execution Logging: Detailed logs of execution steps and timing.
- State Passing: Pass results from one step to the next.
composer require accrossan/step-executeuse Accrossan\StepExecute\StepExecute;
$result = StepExecute::create()
->step('validate', function () {
// Validation logic
return ['valid' => true];
})
->step('process', function ($previousResult) {
// Use result from previous step
return 'Processed';
})
->execute();Automatically wraps steps in a transaction and retries on deadlocks.
$result = StepExecute::createWithTransaction()
->step('create_user', function () {
return User::create([...]);
})
->step('create_profile', function ($user) {
return Profile::create(['user_id' => $user->id]);
})
->execute();StepExecute::create()
->step(
'risky_operation',
fn() => throw new Exception('Fail'),
function ($e, $stepName, $prevResult) {
// Handle error, maybe return a fallback value
return 'fallback';
}
)
->execute();StepExecute::createWithTransaction()
->beforeTransaction(fn() => Log::info('Starting...'))
->onRollback(fn($e) => Log::error('Rolled back: ' . $e->getMessage()))
->afterTransaction(fn($res) => Log::info('Done!'))
->finally(fn($results) => Log::info('Cleanup'))
->execute();Commercial / Proprietary License
Copyright (c) Accrossan. All rights reserved.