PHPackages                             scriptfusion/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. scriptfusion/retry

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

scriptfusion/retry
==================

Retries failing operations.

5.0.1(1y ago)7150.3k↑26%3MITPHPPHP ^8

Since Sep 20Pushed 1y ago3 watchersCompare

[ Source](https://github.com/ScriptFUSION/Retry)[ Packagist](https://packagist.org/packages/scriptfusion/retry)[ RSS](/packages/scriptfusion-retry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (16)Used By (3)

Retry
=====

[](#retry)

[![Latest version](https://camo.githubusercontent.com/3d30749667c81fd25aac8104a169bfa40057403414e3e1bf9110c320504e5fb0/68747470733a2f2f706f7365722e707567782e6f72672f736372697074667573696f6e2f72657472792f762f737461626c65 "Latest version")](https://github.com/ScriptFUSION/Retry/releases)[![Total downloads](https://camo.githubusercontent.com/46f230427a9f2067617a7a243651106b5a3bd9c77b5f9d22d6bd5e3ff8becbcb/68747470733a2f2f706f7365722e707567782e6f72672f736372697074667573696f6e2f72657472792f646f776e6c6f616473 "Total downloads")](https://packagist.org/packages/scriptfusion/retry)[![Build status](https://github.com/ScriptFUSION/Retry/actions/workflows/Tests.yaml/badge.svg "Build status")](https://github.com/ScriptFUSION/Retry/actions/workflows/Tests.yaml)[![Test coverage](https://camo.githubusercontent.com/3eb3e3bc418a464ecf9d3ee7912de9f77b7f5ba9d5af3e1ae991b337132d8ff7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f536372697074465553494f4e2f52657472792f62616467652e737667 "Test coverage")](https://coveralls.io/github/ScriptFUSION/Retry)[![Code style](https://camo.githubusercontent.com/79d87d50eb9f3d8c1efec4e2e4ffbb7047d4aaf9738a483440609e5560739ccd/68747470733a2f2f7374796c6563692e696f2f7265706f732f36323939303535382f736869656c643f7374796c653d666c6174 "Code style")](https://styleci.io/repos/62990558)

Retry provides a function to retry failing operations with optional [Fiber](https://www.php.net/manual/en/language.fibers.php) support. An operation is deemed to have failed if it throws an exception. This library is a rewrite of [Igor Wiedler's retry](https://github.com/igorw/retry) but aims to remain faithful to the spirit of the original.

Requirements
------------

[](#requirements)

- [PHP 8.0](http://php.net/)
- [Composer](https://getcomposer.org/)

Usage
-----

[](#usage)

The `retry` function retries an operation up to the specified number of times with an optional exception handler.

If an exception handler is specified, it is called immediately before retrying the operation. If the handler returns `false`, the operation is not retried.

```
retry(int $times, callable $operation, callable $onError = null);

```

- `$times`—Maximum number of times the operation may run.
- `$operation`—Operation to run up to the specified number of times.
- `$onError`—Optional. Exception handler that receives the thrown exception as its first argument.

Note in the original library, `$times` specifies the number of *retries* and therefore the operation could run up to `$times + 1` times. In this version, `$times` specifies exactly the number of times the operation may run such that if zero (`0`) is specified it will not run.

### Example

[](#example)

The following code fragment attempts to fetch data from a URL over HTTP up to five times.

```
use function ScriptFUSION\Retry\retry;

$response = retry(5, function () use ($url) {
    return HttpConnector::fetch($url);
});
```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~304 days

Recently: every ~359 days

Total

11

Last Release

541d ago

Major Versions

1.1.1 → 2.0.02018-04-19

2.2.1 → 3.0.02021-07-12

3.0.0 → 4.0.02022-10-07

4.0.0 → 5.0.02022-10-31

PHP version history (5 changes)1.0.0PHP ^5.5|^7

2.0.0PHP ^7

2.2.1PHP ^7.2|^8

4.0.0PHP ^8.1

5.0.0PHP ^8

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/470626?v=4)[Bilge](/maintainers/Bilge)[@Bilge](https://github.com/Bilge)

---

Top Contributors

[![Bilge](https://avatars.githubusercontent.com/u/470626?v=4)](https://github.com/Bilge "Bilge (15 commits)")[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[danharrin/date-format-converter

Convert token-based date formats between standards.

3222.4M7](/packages/danharrin-date-format-converter)[corcel/acf

Advanced Custom Field (ACF) plugin for Corcel

132343.9k7](/packages/corcel-acf)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)[contributte/event-dispatcher

Best event dispatcher / event manager / event emitter for Nette Framework

292.4M19](/packages/contributte-event-dispatcher)[carbon/includeassets

Include your assets (css, js) in an easy way into Neos

14228.6k10](/packages/carbon-includeassets)[havokinspiration/wrench

Maintenance mode plugin for CakePHP 3.X

2661.2k](/packages/havokinspiration-wrench)

PHPackages © 2026

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