PHP code example of rap2hpoutre / nestor

1. Go to this page and download the library: Download rap2hpoutre/nestor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rap2hpoutre / nestor example snippets


$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();