PHPackages                             divineomega/attempt - 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. divineomega/attempt

Abandoned → [jord-jd/attempt](/?search=jord-jd%2Fattempt)Library[Utility &amp; Helpers](/categories/utility)

divineomega/attempt
===================

Attempt to run a function, retrying if needed

v3.0.0(2mo ago)25LGPL-3.0-onlyPHPPHP &gt;=7.1

Since Jan 4Pushed 2mo agoCompare

[ Source](https://github.com/Jord-JD/attempt)[ Packagist](https://packagist.org/packages/divineomega/attempt)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-attempt/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

🔁 Attempt
=========

[](#-attempt)

This PHP package allows you to attempt to run a function, automatically retrying if an exception occurs.

It can useful for:

- Unreliable connectivity or APIs
- Interaction with rate-limited systems
- Handling unreliable input data

Installation
------------

[](#installation)

To install Attempt, just run the following command.

```
composer require jord-jd/attempt
```

Usage
-----

[](#usage)

See the following usage examples.

```
// Attempts to run the function immediately. If an exception occurs, retry forever.
attempt(function() {
    // ...
})->now();

// Attempts to run the function immediately. If an exception occurs, retry up to 5 times.
attempt(function() {
    // ...
})->maxAttempts(5)
  ->now();

// Attempts to run the function immediately. If an exception occurs, retry until the specified date time.
attempt(function() {
    // ...
})->until($datetime)
  ->now();

// Attempts to run the function immediately. If an exception occurs, retry forever, with a 20 second gap between attempts.
attempt(function() {
    // ...
})->withGap(20)
  ->now();

// Attempts to run the function at a specified date time. If an exception occurs, retry forever. The thread will block until the specified date time is reached.
attempt(function() {
    // ...
})->at($datetime);
```

Most of these methods can be chained and used together as you might expect to give the desired functionality.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance82

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

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

Total

4

Last Release

89d ago

Major Versions

v1.0.1 → v2.0.02026-02-14

v2.0.0 → v3.0.02026-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (17 commits)")

---

Tags

attemptexception-handlingexceptionsphprate-limits

### Embed Badge

![Health badge](/badges/divineomega-attempt/health.svg)

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

PHPackages © 2026

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