PHP code example of moe-mizrak / transaction-builder
1. Go to this page and download the library: Download moe-mizrak/transaction-builder 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/ */
moe-mizrak / transaction-builder example snippets
$result = TransactionBuilder::make()
->attempts(3) // number of attempts
->run(function () {
// your transaction logic
return 'done';
})
->result();
$result = TransactionBuilder::make()
->run(function () {
throw new \Exception("fail");
})
->onFailure(function ($exception) {
logger()->error($exception->getMessage());
})
->disableThrow() // optional if you want to disable throwing exceptions since you already have onFailure callback
->result();