PHPackages                             derekdowling/stubborn - 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. derekdowling/stubborn

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

derekdowling/stubborn
=====================

Configurable call handler that is persistent against failures.

0.1.2(11y ago)3615.7k1[2 issues](https://github.com/derekdowling/stubborn/issues)MITPHP

Since Jun 26Pushed 11y ago3 watchersCompare

[ Source](https://github.com/derekdowling/stubborn)[ Packagist](https://packagist.org/packages/derekdowling/stubborn)[ RSS](/packages/derekdowling-stubborn/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (5)Used By (0)

Stubborn
--------

[](#stubborn)

[![Gitter](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/derekdowling/stubborn?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![build status](https://camo.githubusercontent.com/88b94c7ff09c11503efb9e1cb6373e2482919962bdff09e8da6035f9aa22e128/68747470733a2f2f7472617669732d63692e6f72672f646572656b646f776c696e672f73747562626f726e2e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/88b94c7ff09c11503efb9e1cb6373e2482919962bdff09e8da6035f9aa22e128/68747470733a2f2f7472617669732d63692e6f72672f646572656b646f776c696e672f73747562626f726e2e7376673f6272616e63683d6d6173746572)

##### Configurable call handler that is persistent against failures.

[](#configurable-call-handler-that-is-persistent-against-failures)

###### Built, tested, and relied upon at [Mover.io](https://mover.io).

[](#built-tested-and-relied-upon-at-moverio)

Frustrated by unreliable APIs that seem to fail randomly? Use Stubborn to ensure you aren't left unprotected in the most vulnerable and unknown spots in your code.

Stubborn provides all the necessary tooling you need to handle a variety of external API calls:

-Result Handling -Retry Handling(immediate/delayed) -Exception Catching -Backoff Handling

###### Example:

[](#example)

```
$id = $_RESULT['user_id'];

// $result will contain either the result from each attempt, or the exception
// each attempt threw
$result = Stubborn::build()
    // Use the Stubborn Result Handler to drive your call retries
    ->resultHandler(
        function ($stubborn) use ($id) {
            // fetch the latest attempt result returned from
            // whatever you called in the the run function
            $result = $stubborn->result();

            if ($result == 'Success_Result') {
                // use the Event Handler to drive Stubborn
                $stubborn->accept();
            } elseif ($result == 'Backoff_Needed_Result') {
                // Let Stubborn backoff for 3 seconds, then retry
                $stubborn->staticBackoff(3);
            } elseif ($result == 'Not_Yet_Persisted_Result') {
                // Let Stubborn Delay, Then Retry
                $stubborn->delayRetry();
            } elseif ($result == 'Hard_Failure_Result') {
                // Sometimes, giving up is the best option
                $stubborn->stop();
            } elseif ($result == 'Restart_Run_Result') {
                // Allows you to restart the run from scratch
                $stubborn->reset();
            } elseif ($result == 'Requires_Modification_Result') {
                // Start over, but with a slightly modified API Call
                $stubborn->resetAndRun(function () use ($id) {
                     Awesome_API::add_subscriber($id, false);
                });
            } else {
                $stubborn->retry();
            }
        }
    // Handle exceptions more explicitly and perform backoff using
    // a predefined set of tools, or perform your own handling manually
    )->exceptionHandler(function ($stubborn) {

        if (is_a($stubborn->exception(), 'Awesome_API\BackoffException')) {
            // exponentially increasing backoff after each attempt
            $stubborn->exponentialBackoff();
        } else {
            // wait three seconds before trying again
            $stubborn->staticBackoff(3);
        }

    })
    // Retry if defined exceptions are thrown by your function
    ->catchExceptions(array('Awesome_API\UnexpectedError'))
    // Will retry up to four times after the first attempt
    ->retries(4)
    ->run(function() use ($id) {
        return Awesome_API::add_subscriber($id);
    });
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.7% 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

2

Last Release

4190d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/613964?v=4)[Derek Dowling](/maintainers/derekdowling)[@derekdowling](https://github.com/derekdowling)

---

Top Contributors

[![derekdowling](https://avatars.githubusercontent.com/u/613964?v=4)](https://github.com/derekdowling "derekdowling (43 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

---

Tags

phpretry-strategies

### Embed Badge

![Health badge](/badges/derekdowling-stubborn/health.svg)

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

###  Alternatives

[csharpru/vault-php

Best Vault client for PHP that you can find

8410.3M4](/packages/csharpru-vault-php)[composer-unused/contracts

Contract repository for composer-unused

115.7M2](/packages/composer-unused-contracts)

PHPackages © 2026

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