https://github.com/rap2hpoutre/nestor
:tropical_drink: Do task, rollback if something goes wrong. Just like database transactions.
https://github.com/rap2hpoutre/nestor
nestor php task-runner
Last synced: about 2 months ago
JSON representation
:tropical_drink: Do task, rollback if something goes wrong. Just like database transactions.
- Host: GitHub
- URL: https://github.com/rap2hpoutre/nestor
- Owner: rap2hpoutre
- License: mit
- Created: 2015-10-02T06:11:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-09-30T12:47:43.000Z (over 4 years ago)
- Last Synced: 2025-03-24T23:51:24.676Z (2 months ago)
- Topics: nestor, php, task-runner
- Language: PHP
- Homepage:
- Size: 242 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nestor Task Servant
[](https://github.com/rap2hpoutre/nestor/releases)
[](LICENSE)
[](https://travis-ci.org/rap2hpoutre/nestor)
[](https://scrutinizer-ci.com/g/rap2hpoutre/nestor/code-structure)
[](https://scrutinizer-ci.com/g/rap2hpoutre/nestor)## Installation
```
composer require rap2hpoutre/nestor
```
## Usage
Run some tasks. In this example, the second task fails, everything will be rolled back.
```php
$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
[](LICENSE)Thanks to [DonoSybrix](https://github.com/DonoSybrix). Feel free to contribute.