PHP code example of tony-sol / retryer

1. Go to this page and download the library: Download tony-sol/retryer 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/ */

    

tony-sol / retryer example snippets


	$result = (new \Retryer\Retryer())
		/** @var callable $action Execute some action */
		->do($action)
		/** @var int $N N times, 1 by default */
		->times($N)
		/** @var int $T with delay T ms between iterations, 0 by default */
		->withDelay($T)
		/** @var bool $isOn = true use exponential backoff between iterations */
		->useExponentialBackoff($isOn) //
		/** @var float $M use linear backoff M multiplier */
		->useLinearBackoffMultiplier($M) //
		/** @note use can use only linear or exponential backoff, by default backoff is constant and equals to T */
		/** @var string[] $exceptions Array of exceptions' FQCN which may interrupt execution */
		->withBreakingExceptions($exceptions)
		/** @note throw exception on last try if failed */
		->throwExceptionOnLastTry()
		->execute();