PHPackages                             graze/transient-fault-handler - 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. graze/transient-fault-handler

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

graze/transient-fault-handler
=============================

Retry tasks that fail due to transient faults

0.3.1(5y ago)424.7k↓50%[1 issues](https://github.com/graze/transient-fault-handler/issues)1MITPHPPHP &gt;=5.5.0

Since Mar 2Pushed 5y ago12 watchersCompare

[ Source](https://github.com/graze/transient-fault-handler)[ Packagist](https://packagist.org/packages/graze/transient-fault-handler)[ Docs](https://github.com/graze/transient-fault-handler)[ RSS](/packages/graze-transient-fault-handler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (6)Used By (1)

Transient Fault Handler
=======================

[](#transient-fault-handler)

[![Latest Version on Packagist](https://camo.githubusercontent.com/09dd9d48c32f44c0fab805703a688b0d5590806994cdf4f0384049636248aba0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772617a652f7472616e7369656e742d6661756c742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/transient-fault-handler)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e5b5b47b075633e78297db3d493d0f79f6331b52d72f55178c61a338c73d48fe/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6772617a652f7472616e7369656e742d6661756c742d68616e646c65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/graze/transient-fault-handler)[![Coverage Status](https://camo.githubusercontent.com/269ff26c12095a43dfe9f9622c05218f30caae071f65537c3cf2b844d626e32f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6772617a652f7472616e7369656e742d6661756c742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/transient-fault-handler/code-structure)[![Quality Score](https://camo.githubusercontent.com/2943612c724379489a6b0d3c2027e81b1b5fcf7e90ed08e9828b69ac904b3a37/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6772617a652f7472616e7369656e742d6661756c742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/transient-fault-handler)[![Total Downloads](https://camo.githubusercontent.com/3ea7bc34f40f00bc7583e2154147664f5a3c8d06e8b03cffe58ba7ddf618a991/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6772617a652f7472616e7369656e742d6661756c742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/transient-fault-handler)

Retries tasks that fail due to transient errors. Well suited to network requests but can retry any callable.

Install
-------

[](#install)

Via Composer

```
composer require graze/transient-fault-handler
```

Usage
-----

[](#usage)

The transient fault handler takes two detection strategies and a retry strategy. The builder can be used to quickly create a handler.

```
$task = function () {
    // Task that is prone to transient errors
};

$builder = new TransientFaultHandlerBuilder();
$transientFaultHandler = $builder->build();

$result = $transientFaultHandler->execute($task);
```

### Detection Strategy

[](#detection-strategy)

When a task is tried, it will either return some value or throw an exception.

The detection strategies will decide if that value/exception indicates a transient error or not.

If it does, then the fault handler will be told to retry the task. if it does not, then the value/exception either indicates a success or a non-transient error that retrying wouldn't solve.

In these cases, the value is returned to the caller or the exception is rethrown.

- `FalseyReturnValueDetectionStrategy`: treats return values that [evaluate to false](http://php.net/manual/en/types.comparisons.php) as transient.
- `StaticDetectionStrategy`: returns a static value set when constructing the strategy, regardless of the return value or exception.

### Retry Strategy

[](#retry-strategy)

If the detection strategy decides that the task should be retried, the retry strategy will decide how long to wait before doing so (the backoff period), and optionally impose a maximum number of retries on the task.

- `ExponentialBackoffStrategy`: the backoff period is chosen randomly between zero and an exponentially increasing maximum.

### Builder

[](#builder)

The builder makes it easier to create a fault handler by automatically injecting dependencies. The default strategies that the builder uses can be overridden by using the setters.

```
$builder = new TransientFaultHandlerBuilder();
$transientFaultHandler = $builder
    ->setExceptionDetectionStrategy(new StaticDetectionStrategy())
    ->setReturnValueDetectionStrategy(new FalseyReturnValueDetectionStrategy())
    ->setRetryStrategy(new ExponentialBackoffStrategy())
    ->setLogger(new Logger())
    ->build();
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
make test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Jake Wright](https://github.com/jakewright)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~406 days

Total

4

Last Release

2144d ago

### Community

Maintainers

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

---

Top Contributors

[![biggianteye](https://avatars.githubusercontent.com/u/1482649?v=4)](https://github.com/biggianteye "biggianteye (6 commits)")[![jakewright](https://avatars.githubusercontent.com/u/5333300?v=4)](https://github.com/jakewright "jakewright (5 commits)")

---

Tags

retrynetworkinggrazetransient fault

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/graze-transient-fault-handler/health.svg)

```
[![Health](https://phpackages.com/badges/graze-transient-fault-handler/health.svg)](https://phpackages.com/packages/graze-transient-fault-handler)
```

###  Alternatives

[graze/telnet-client

Telnet client written in PHP

50233.9k4](/packages/graze-telnet-client)[vkartaviy/retry

The library for repeatable and retryable operations

29227.2k2](/packages/vkartaviy-retry)[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)[yriveiro/php-backoff

Simple backoff / retry functionality

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

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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