Skip to content

Quickstart

Quickstart

composer require cboxdk/laravel-operations
php artisan migrate

Start an operation, advance its steps, and finish:

use Cbox\Operations\Contracts\Operations;
use Cbox\Operations\DataObjects\{StartOperation, AdvanceStep, CompleteOperation};

$operations = app(Operations::class);

$op = $operations->start(new StartOperation(
    kind: 'deploy',
    targetType: 'workload',
    targetId: 'wl_123',
    steps: ['build', 'release', 'route'],
    expiresAt: now()->addMinutes(15),
));

$operations->advanceStep(new AdvanceStep($op->id, 'build'));
$operations->advanceStep(new AdvanceStep($op->id, 'release'));
$operations->advanceStep(new AdvanceStep($op->id, 'route'));
$operations->complete(new CompleteOperation($op->id));

Schedule the stall sweep so a crashed worker's operation self-heals:

use Illuminate\Support\Facades\Schedule;

Schedule::command('operations:sweep-stalled')->everyMinute();

Watch progress by listening for Cbox\Operations\Events\OperationUpdated and forwarding its broadcastWith() payload to your transport of choice.