rap2hpoutre/nestor

Do task, rollback if something goes wrong. Just like database transactions.
10,239 4
Install
composer require rap2hpoutre/nestor
Latest Version:v0.0.3
License:MIT
Last Updated:Sep 30, 2020
Links: GitHub  ·  Packagist
Maintainer: rap2hpoutre

Nestor Task Servant

Latest Version Software License Build Status Coverage Status Quality Score

Installation

composer require rap2hpoutre/nestor

Usage

Run some tasks. In this example, the second task fails, everything will be rolled back.

$nestor = new Nestor\Servant;

// Create 1st task
$nestor->task()
    ->up(function (){
        echo "task 1 done\n";
    })
    ->down(function () {
        echo "task 1 cancelled\n";
    });
    
// Create 2nd task (will fail)
$nestor->task()
    ->up(function ($nestor) {
        $nestor->fail();
        echo "task 2 done\n";
    })
    ->down(function () {
        echo "task 2 cancelled\n";
    });
    
// Run all tasks, rollback on fail (LIFO stack)
$nestor->run();

You should see:

task 1 done
task 2 cancelled
task 1 cancelled

Why?

Todo: Explain why.

About

Software License

Thanks to DonoSybrix. Feel free to contribute.

Related Packages

jeroen-g/laravel-packager

A cli tool for creating Laravel packages.

735,256 1,370
lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users...

19,094,858 2,336
jrenton/laravel-5-scaffold

Fastest way to rapidly scaffold a laravel application

268 4
igaster/laravel-theme

Laravel Themes: Asset & Views folder per theme. Theme inheritance. Blade integra...

1,257,366 515
bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2,546,238 280