Skip to content

[13.x] Allow Http Client to be used as PSR Client#60295

Merged
taylorotwell merged 3 commits into
laravel:13.xfrom
willrowe:feature/http-optional-laravel-data
May 27, 2026
Merged

[13.x] Allow Http Client to be used as PSR Client#60295
taylorotwell merged 3 commits into
laravel:13.xfrom
willrowe:feature/http-optional-laravel-data

Conversation

@willrowe
Copy link
Copy Markdown
Contributor

This makes some options used internally by the Http client optional so that the client returned by buildClient can be used anywhere that an instance of \Psr\Http\Client\ClientInterface is required. This allows the middleware and the handler stack to be used on all requests made using the client, which means things like request logging will also apply.

For example, say your application uses a package that allows address geocoding and has different drivers available for different map providers. The service class in this package must be instantiated with an instance of \Psr\Http\Client\ClientInterface, which it then uses to make API requests to the corresponding map providers. By passing the Laravel Http client, all requests and responses from these APIs can then be logged alongside all the other Http requests being made directly by application code.

$geocoder = new GeocodingService(Http::buildClient());

@willrowe willrowe force-pushed the feature/http-optional-laravel-data branch from 86b660c to 0af4f91 Compare May 27, 2026 15:43
@taylorotwell taylorotwell merged commit 7347426 into laravel:13.x May 27, 2026
51 of 52 checks passed
@willrowe willrowe deleted the feature/http-optional-laravel-data branch May 28, 2026 14:22
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