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.2.0(1y ago)21.6kMITPHPPHP ^8.1CI passing

Since Oct 2Pushed 1y 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 1mo ago

READMEChangelog (4)Dependencies (7)Versions (5)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

35

—

LowBetter than 79% of packages

Maintenance46

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Total

4

Last Release

437d 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 (19 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

[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[tomschlick/laravel-http2-server-push

A middleware package for Laravel to enable server push for your script, style, and image assets.

16467.2k](/packages/tomschlick-laravel-http2-server-push)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

1935.1k](/packages/onlime-laravel-http-client-global-logger)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[laragear/json

Easily retrieve and manipulate `Json` across your application.

363.5k](/packages/laragear-json)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)

PHPackages © 2026

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