Skip to content

Conversation

@cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Nov 28, 2025

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
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