Skip to content

[12.x] Introduce FluentPromise to allow for cleaner chaining in Pool - #57967

Merged
taylorotwell merged 5 commits into
laravel:12.xfrom
cosmastech:laravel-fluent-promise
Nov 28, 2025
Merged

[12.x] Introduce FluentPromise to allow for cleaner chaining in Pool#57967
taylorotwell merged 5 commits into
laravel:12.xfrom
cosmastech:laravel-fluent-promise

Conversation

@cosmastech

@cosmastech cosmastech commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Guzzle Promises are immutable, which means userland chaining in Pool is not possible since we don't have access to the underlying array.

For example, this will not work to return the string length of each request. It will instead just return the responses.

$response = Http::pool(function (Pool $pool) {
    $pool->as('cosmatech')
        ->get('https://cosmastech.com')
        ->then(
            fn ($response) => strlen($response->body())
        );
    $pool->as('laravel')
        ->get('https://laravel.com')
        ->then(
            fn ($response) => strlen($response->body())
        );
});

dd($response);
/*
array:2 [
  "cosmatech" => Illuminate\Http\Client\Response {
   ...
   },
   "laravel" => Illuminate\Http\Client\Response {
   ...
   }
]
*/

Were this PR to be accepted, then the above will produce:

/*
array:2 [
  "cosmatech" => 9095
  "laravel" => 1422023
]
*/

@cosmastech
cosmastech marked this pull request as draft November 28, 2025 16:45
@cosmastech
cosmastech marked this pull request as ready for review November 28, 2025 16:48
@cosmastech cosmastech changed the title [12.x] FluentPromise [12.x] Introduce FluentPromise to allow for cleaner chaining in Pool callbacks Nov 28, 2025
@cosmastech cosmastech changed the title [12.x] Introduce FluentPromise to allow for cleaner chaining in Pool callbacks [12.x] Introduce FluentPromise to allow for cleaner chaining in Pool Nov 28, 2025
@taylorotwell
taylorotwell merged commit 5d712fb into laravel:12.x Nov 28, 2025
73 of 74 checks passed
akyrey pushed a commit to akyrey/framework that referenced this pull request Dec 29, 2025
laravel#57967)

* laravel fluent promise

* docblocks

* protected

* Update PendingRequest.php

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
@cosmastech
cosmastech deleted the laravel-fluent-promise branch January 24, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants