PHPackages                             apacheborys/re-try-php - 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. apacheborys/re-try-php

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

apacheborys/re-try-php
======================

Library to operate retries in your php application

0.15.4(3y ago)01132MITPHPPHP ^7.4||^8.0

Since Sep 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/apacheborys/re-try-php)[ Packagist](https://packagist.org/packages/apacheborys/re-try-php)[ RSS](/packages/apacheborys-re-try-php/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (12)Used By (2)

ReTry mechanism for any php application
=======================================

[](#retry-mechanism-for-any-php-application)

[![ReTry](https://github.com/apacheborys/re-try-php/actions/workflows/php.yml/badge.svg)](https://github.com/apacheborys/re-try-php/actions/workflows/php.yml)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

That library still in development phase. Please don't use it until first release

With this library you will be able to introduce re-try approach in simple way:

1. Create configuration
2. When your application start, please add next 2 rows in the begining:

```
$factory = new \ApacheBorys\Retry\HandlerFactory($config);
$retry = $factory->createExceptionHandler($yourContainer);
```

3. Start by another process code like that:

```
$factory = new \ApacheBorys\Retry\HandlerFactory($config);
$worker = $factory->createMessageHandler($yourContainer);
while (true) {
    $worker->processRetries();
    sleep(1);
}
```

Config example:

```
{
    /**
      * here we can define declarator what should register exception handling callback function, if you are plan to use
      * standard php function set_exception_handler - you can ignore that section. StandardHandlerExceptionDeclarator is default
     **/
    "handlerExceptionDeclarator": {
      "class": "ApacheBorys\\Retry\\HandlerExceptionDefiner\\StandardHandlerExceptionDeclarator",
      "arguments": []
    },
    "items": {
      /* name of retry */
      "test": {
        /* what type of Exception we would like to retry */
        "exception": "ApacheBorys\\Retry\\Tests\\Functional\\Exceptions\\Mock",
        /* how many tries we should do */
        "maxRetries": 4,
        /* here we are describing formula, how next execution time should be calculated. Calculated amount will be added to current time */
        "formula": [
          {
            /* here available *, -, + and / operators */
            "operator": "+",
            /* you can use QTY_TRIES operator or any integer value */
            "argument": "QTY_TRIES"
          },
          {
            "operator": "*",
            "argument": "5"
          }
        ],
        /* here you should define, what kind of transport you would use to deliver re-try messages to worker. Please pay your attention to https://github.com/apacheborys/re-try-php-basics-lib */
        "transport": {
          "class": "ApacheBorys\\Retry\\Tests\\Functional\\Transport\\FileTransportForTests",
          /* each specific transport could have own arguments in constructor. Here you should define it */
          "arguments": [
            "tests\/transport.data"
          ]
        },
        /* here you should define, what kind of executor you would use to perform re-try action */
        "executor": {
          "class": "ApacheBorys\\Retry\\Tests\\Functional\\Executor\\Runtime",
          /* each specific executor could have own arguments in constructor. Here you should define it */
          "arguments": []
        }
      }
    }
}
```

The notice about `handlerExceptionDeclarator`, `transport` and `executor`:

As second argument for constructor of `ApacheBorys\Retry\ExceptionHandler` and `ApacheBorys\Retry\MessageHandler` you can send ContainerInterface. In this case, you can define arguments for `handlerExceptionDeclarator`, `transport` and `executor` as instances from runtime. It will be fetched from this injected Container.

For example:

```
...
    "transport": {
        "class": "ApacheBorys\\Retry\\BasicTransport\\PdoTransport,
        "arguments": [
            "@pdoInstanceFromYourContainer"
        ]
    },
...
```

Leading `@` indicates - you are trying to inject some instance from your container.

Also, if you don't want to use Container to inject some instances from runtime. But you still need to create some instances to ensure proper execution for `handlerExceptionDeclarator`, `transport` and `executor`, you can use next construction:

```
...
    "transport": {
        "class": "ApacheBorys\\Retry\\BasicTransport\\PdoTransport,
        "arguments": [
            [
                    "class": "\\PDO",
                    "arguments": [
                        "sqlite:/app/storage/retry-db.data'"
                    ]
            ]
        ]
    },
...
```

In this case, handler/declarator will try to instantiate described class with arguments. In these arguments you can use same tricks with leading `@`; and `class`, `arguments` constructions.

Leading `@` works with `class` too.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

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 ~26 days

Recently: every ~4 days

Total

11

Last Release

1130d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1dbfc3e2a454a36796b4fd5b7877271983a2e185ae75428c303b32d9d9d89589?d=identicon)[apacheborys](/maintainers/apacheborys)

---

Top Contributors

[![apacheborys](https://avatars.githubusercontent.com/u/11578023?v=4)](https://github.com/apacheborys "apacheborys (56 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/apacheborys-re-try-php/health.svg)

```
[![Health](https://phpackages.com/badges/apacheborys-re-try-php/health.svg)](https://phpackages.com/packages/apacheborys-re-try-php)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k52](/packages/ecotone-ecotone)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[wikimedia/parsoid

Parsoid, a bidirectional parser between wikitext and HTML5

187557.3k3](/packages/wikimedia-parsoid)

PHPackages © 2026

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