PHPackages                             cbaconnier/laravel-http-pool-callback - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. cbaconnier/laravel-http-pool-callback

ActiveLibrary[HTTP &amp; Networking](/categories/http)

cbaconnier/laravel-http-pool-callback
=====================================

A Laravel package that enhances the HTTP pool functionality by allowing users to apply callbacks to the results.

1.3.0(1w ago)22.2kMITPHPPHP ^8.1CI passing

Since Oct 2Pushed 1w ago1 watchersCompare

[ Source](https://github.com/cbaconnier/laravel-http-pool-callback)[ Packagist](https://packagist.org/packages/cbaconnier/laravel-http-pool-callback)[ RSS](/packages/cbaconnier-laravel-http-pool-callback/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (14)Versions (6)Used By (0)

Laravel HTTP Pool - Callback
============================

[](#laravel-http-pool---callback)

Laravel HTTP Pool - Callback is a package that enhances the HTTP pool functionality in Laravel. It allows users to apply callbacks to the results of HTTP requests made using Laravel's HTTP pool. This makes it easier to process and manipulate the responses as needed.

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

[](#installation)

You can install the package via Composer:

```
composer require cbaconnier/laravel-http-pool-callback
```

Usage
-----

[](#usage)

### Prepare the requests

[](#prepare-the-requests)

You must implement the `HttpPoolAware` interface and use the `HasHttpPool` trait in your repository classes.
This will allow you to register callbacks to be applied to the responses of the requests.

```
use GuzzleHttp\Promise\PromiseInterface;
use Cbaconnier\HttpPool\HttpPoolAware;
use Cbaconnier\HttpPool\HasHttpPool;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\Client\Response;

class InvoiceRepository implements HttpPoolAware
{

    use HasHttpPool;

    public function findAsync(int $id): PromiseInterface
    {
        $promise = $this->http()->get("https://example.com/invoices/{$id}");

        // Register the callback that will be executed on the response
        $this->onPromiseResolved(function (Response $response) {
            return new InvoiceDto($response->getBody()->getContents());
        });

        return $promise;
    }

    public function find(int $id): InvoiceDto
    {
        // You can still use the repository without async requests as well
        $response = $this->http()->get("https://example.com/invoices/{$id}");

        return new InvoiceDto($response->getBody()->getContents());
    }

    // Not necessary but here to demonstrate a common use case
    // Then use $this->client()->get(...) instead of $this->http()->get(...)
    public function client(): PendingRequest
    {
        return $this->http()
        ->withHeaders([
            'Authorizations' => 'Bearer ...'
        ])
        ->withOptions([
            // ..
        ]);
    }

}
```

### Pool the requests and apply the callbacks

[](#pool-the-requests-and-apply-the-callbacks)

`runAsync` will clone your repositories instances to no infer with other requests and delegate the requests to the native `Http::pool()` method.
By doing so, you can still benefit from the `Http` methods and testing helpers.

When you call `getResponses`, it will returns the default Laravel `Response` objects.
When you call `getResolved`, it will apply the `callbacks` to the responses and returns the results.

```
use Cbaconnier\HttpPool\Facades\HttpPool;

$pool = HttpPool::runAsync([
        'invoice' => $invoiceRepository->async(fn (InvoiceRepository $repository) => $repository->findAsync(123)),
        'client' => $clientRepository->async(fn (ClientRepository $repository) => $repository->findAsync(123)),
    ]);

$pool->getResponses(); // Returns ['invoice' => Response, 'client' => Response]
$pool->getResolved();  // Returns ['invoice' => InvoiceDto, 'client' => ClientDto]

// You can also use macro instead of facade
Http::runAsync([ ... ])->getResolved();
```

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Clément Baconnier](https://github.com/cbaconnier)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance98

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Total

5

Last Release

12d ago

### Community

Maintainers

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

---

Top Contributors

[![cbaconnier](https://avatars.githubusercontent.com/u/4738184?v=4)](https://github.com/cbaconnier "cbaconnier (20 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/cbaconnier-laravel-http-pool-callback/health.svg)

```
[![Health](https://phpackages.com/badges/cbaconnier-laravel-http-pool-callback/health.svg)](https://phpackages.com/packages/cbaconnier-laravel-http-pool-callback)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.9k1](/packages/mike-bronner-laravel-model-caching)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[illuminate/routing

The Illuminate Routing package.

1419.2M3.0k](/packages/illuminate-routing)

PHPackages © 2026

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