rap2hpoutre/nestor
最新稳定版本:v0.0.3
Composer 安装命令:
composer require rap2hpoutre/nestor
包简介
Do task, rollback if something goes wrong. Just like database transactions.
README 文档
README
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
Thanks to DonoSybrix. Feel free to contribute.
统计信息
- 总下载量: 10.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-02