PHPackages                             configured/race - 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. configured/race

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

configured/race
===============

Race for Laravel: run multiple attempts concurrently and return the first valid result.

v0.2.1(1mo ago)1418—0%MITPHPPHP ^8.3CI passing

Since May 5Pushed 1w agoCompare

[ Source](https://github.com/configuredco/race)[ Packagist](https://packagist.org/packages/configured/race)[ RSS](/packages/configured-race/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

Race for Laravel
================

[](#race-for-laravel)

Run multiple forked attempts concurrently and return the first valid result.

Race for Laravel requires PHP 8.3+, PCNTL, POSIX, and socket support. It does not use queues, so `times: 5` means five child processes are forked immediately from the current PHP process.

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

[](#installation)

```
composer require configured/race:^0.1.0
```

Publish the config file if you want to customize timing behavior:

```
php artisan vendor:publish --tag=race-config
```

```
return [
    'poll_interval_ms' => 10,
    'execution_buffer_seconds' => 5,
];
```

`execution_buffer_seconds` is added to the race timeout when Race temporarily raises PHP's `max_execution_time`. For example, `timeout(60)` with the default buffer sets the process execution limit to 65 seconds while the race runs, then restores the previous limit.

Usage
-----

[](#usage)

```
$result = race(
    times: 3,
    timeout: 20,
    callback: fn () => Ai::agent()->prompt($prompt, timeout: 15),
    valid: fn ($result) => filled((string) $result),
    map: fn ($result) => (string) $result,
);
```

```
use Configured\Race\Exceptions\RaceFailedException;

$result = Race::times(3)
    ->timeout(20)
    ->valid(fn ($result) => filled($result))
    ->map(fn ($result) => (string) $result)
    ->failed(function (RaceFailedException $failure): string {
        logger()->warning('All race attempts failed.', [
            'attempts' => $failure->attempts(),
            'timed_out' => $failure->timedOut(),
            'failures' => $failure->failures(),
            'invalid_results' => $failure->invalidResults(),
        ]);

        return 'fallback';
    })
    ->run(fn () => Ai::agent()->prompt($prompt, timeout: 15));
```

The first attempt that passes the `valid` callback wins. Remaining child processes are terminated and ignored.

The `failed` callback runs only when the whole race fails. It receives a `RaceFailedException` with the number of attempts, failed attempt details, invalid results, and whether the race timed out. If the callback returns a value, that value is returned as the race result.

Available failure details:

```
$failure->attempts();       // Total attempts considered by the race.
$failure->timedOut();       // True when child processes were still running at timeout.
$failure->failures();       // Thrown attempt errors: attempt, class, message.
$failure->invalidResults(); // Results that completed but failed your valid callback.
```

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance96

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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

Total

4

Last Release

35d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dafd56686be05c299f7a27d83fb6fb6b277f8efc62d563632fa93706f16a426f?d=identicon)[campo](/maintainers/campo)

---

Top Contributors

[![joecampo](https://avatars.githubusercontent.com/u/3619398?v=4)](https://github.com/joecampo "joecampo (6 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/configured-race/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M264](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M984](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M356](/packages/illuminate-redis)[atlas-php/atlas

A unified AI SDK for Laravel applications.

5034.0k](/packages/atlas-php-atlas)

PHPackages © 2026

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