PHPackages                             graceas/php-retry - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. graceas/php-retry

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

graceas/php-retry
=================

A library for retrying actions that can fail.

v0.0.3(6y ago)06MITPHPPHP &gt;=5.5.9CI failing

Since Dec 22Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Graceas/php-retry)[ Packagist](https://packagist.org/packages/graceas/php-retry)[ RSS](/packages/graceas-php-retry/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Retry
=====

[](#retry)

A library for retrying actions that can fail.

Installation
============

[](#installation)

Through composer:

```
"require": {
    ...
    "graceas/php-retry": "v0.0.3"
    ...
}

```

Usage (general example)
=======================

[](#usage-general-example)

```
$retry = new Retry();

$i = 0;

$retry->retry(
    new RetryAction(
        // can pass any action that can fail (database query, curl loading, etc)
        function() use (&$i) {
            // simulate non-periodic error (eg broken database connection)
            $i++;

            return ($i > 3) ? $i : 1 / 0;
        },
        4 // expect 4 as result for callable function
    ),
    new LinearRetryStrategy(10 /* timeout ms */, 5 /* retrying times */)
);

if ($retry->isSuccess()) {
    // task success
} else {
    // task failed
    // echo $retry->getLog();
}

```

Example Output
==============

[](#example-output)

```
echo $retry->getLog();

> 1577074792: [1 of 5] [sleep 10] Division by zero in /Users/gorelov/projects/php-retry/tests/RetryTest.php on line 52
> 1577074792: [2 of 5] [sleep 10] Division by zero in /Users/gorelov/projects/php-retry/tests/RetryTest.php on line 52
> 1577074792: [3 of 5] [sleep 10] Division by zero in /Users/gorelov/projects/php-retry/tests/RetryTest.php on line 52
> 1577074977: [4 of 5] [sleep 10] success

```

Backoff Strategies
==================

[](#backoff-strategies)

LinearRetryStrategy - Each attempt waits a configured time.

ExponentialRetryStrategy - The base delay time is calculated as: time ^ attempt where attempt is the number of unsuccessful attempts that have been made.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

2338d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd86282716d0a29e62ac25f6b5ad3e03bf3155700437aba1da4829f8b46d974a?d=identicon)[Graceas](/maintainers/Graceas)

---

Top Contributors

[![Graceas](https://avatars.githubusercontent.com/u/3995794?v=4)](https://github.com/Graceas "Graceas (23 commits)")

---

Tags

retrybackoffretrying

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/graceas-php-retry/health.svg)

```
[![Health](https://phpackages.com/badges/graceas-php-retry/health.svg)](https://phpackages.com/packages/graceas-php-retry)
```

###  Alternatives

[vkartaviy/retry

The library for repeatable and retryable operations

29227.2k2](/packages/vkartaviy-retry)[yriveiro/php-backoff

Simple backoff / retry functionality

2675.1k1](/packages/yriveiro-php-backoff)[eventsauce/backoff

Back-off strategy interface

70811.9k6](/packages/eventsauce-backoff)[tobion/retry

A generic library to retry an operation in case of an error. You can configure the behavior like the exceptions to retry on.

16396.8k](/packages/tobion-retry)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
