PHP code example of exan / reactphp-retrier
1. Go to this page and download the library: Download exan/reactphp-retrier 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/ */
exan / reactphp-retrier example snippets
use Exan\Retrier\Retrier;
$retrier = new Retrier();
$result = $retrier->retry(3, fn () => new Promise(function ($resolve, $reject) {
// This will be executed up to 3 times
$resolve('Success!');
}));
$result->then(function ($res) {
echo $res; // 'Success!'
});
use Exan\Retrier\Retrier;
$result = Retrier::attempt(3, fn () => new Promise(function ($resolve, $reject) {
// This will be executed up to 3 times
$resolve('Success!');
}));
$result->then(function ($res) {
echo $res; // 'Success!'
});