1. Go to this page and download the library: Download gousto/replay 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/ */
gousto / replay example snippets
use Gousto\Replay\Replay;
try {
$result = Replay::retry(3, function() {
return Http::get('example.com');
}, 50);
Log::info("All good");
} catch(\Gousto\Replay\RetryLogicException $e) {
\Log::error("After 3 times the function still error out!");
}
use Gousto\Replay\Replay;
$replay = Replay::times(3, function() {
throw new LogicException();
}, 10);
$replay->onRetry(function(Exception $e, Replay $replay) {
$replay->setDelay($replay->getDelay() * 2);
});
// play the strategy!
$replay->play();
use Gousto\Replay\Replay;
// Will throw LogicException and not retry
Replay::retry(3, function() {
throw new LogicException();
}, 0, [RuntimeException::class]);
use Gousto\Replay\Replay;
Replay::retry(1, function() {
throw new Exception();
}, 0, [Exception::class]);
use Gousto\Replay\Replay;
$replay = Replay::times(1, function() {
throw new Exception();
}, 0, [Exception::class]);
$replay->play();