Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Http Client Laravel Package

react/http-client

Deprecated ReactPHP streaming, event-driven HTTP client kept for BC. Development moved to react/http with a new Promise-based, PSR-7 Browser API. Upgrade recommended; see react/http for current client usage and features.

View on GitHub
Deep Wiki
Context7

Getting Started

This package is deprecated as of 2021-04-07 and has been fully migrated into react/http. Do not start new projects with react/http-client—migrate immediately if you're still using it. The modern replacement uses PSR-7/18-compatible Browser instances and Promises for cleaner async code.

If you inherited legacy code using React\HttpClient\Client, the migration path is straightforward:

  1. Replace react/http-client with react/http
  2. Update imports from React\HttpClient\* to React\Http\*
  3. Replace Client/Request event-streaming pattern with Browser methods returning Promises (see below)

Example upgrade:

composer remove react/http-client && composer require react/http

Then refactor old streaming code:

// ❌ OLD (deprecated)
$client = new React\HttpClient\Client($loop);
$request = $client->request('GET', $url);
$request->on('response', fn($res) => $res->on('data', fn($chunk) => echo $chunk));

// ✅ NEW (recommended)
$browser = new React\Http\Browser($loop);
$browser->get($url)->then(fn($res) => echo $res->getBody());

Implementation Patterns

Legacy usage (still seen in older codebases):

  • Create Client with EventLoopInterface + optional ConnectorInterface
  • Build requests with request($method, $uri, $headers)write()end()
  • Handle responses via events (response, data, end, error, close)
  • Pipe streams into request bodies for efficient large uploads

Modern equivalents in react/http:

  • Use React\Http\Browser for all HTTP operations (GET/POST/etc. as named methods)
  • All methods return React\Promise\PromiseInterface resolving to Psr\Http\Message\ResponseInterface
  • Chain errors via ->otherwise() or try/catch with async-aware error handling
  • Streaming handled automatically; use getBody() or pipe() for large responses

Typical workflows:

  • Simple API calls: $browser->get('https://api.example.com/')->then(...)
  • POST with JSON: $browser->post($url, ['Content-Type' => 'application/json'], json_encode($data))
  • Concurrent requests: React\Http\Browser::all([$browser->get($a), $browser->get($b)])
  • Custom timeouts/headers: $browser->withOptions(['timeout' => 5.0])->get(...)

Unix domain sockets (still relevant):

  • Configure Connector with FixedUriConnector pointing to unix:///path/to.sock
  • Use http://localhost/ as target URI (host ignored, UDS path used instead)

Gotchas and Tips

  • ⚠️ Deprecation is final: This package receives no new features. Even critical bugs are fixed only in react/http. Upgrade ASAP.
  • ⚠️ No Promise support: Old code uses streams/events; modern code uses Promises. Mixing patterns causes confusion and subtle bugs.
  • SSL/TLS quirks: Defaults changed in newer ReactPHP versions. Explicitly set TLS options if verifying certs fails in dev environments (e.g., ['verify_peer' => false]).
  • Memory leaks: Legacy Client had known leaks with long-lived connections or large files. The new Browser handles buffering more efficiently.
  • PHP 8+ compatibility: Last http-client release (0.5.11) includes minor fixes for PHP 8, but react/http is the only supported version for modern PHP.
  • Proxy support: Use react/socket’s Connector to configure HTTP/SOCKS proxies—this was easier to misconfigure in older versions.
  • Debugging: Enable event loop logging by piping Client’s connector to a custom logger. In the new API, use $browser->withOptions(['debug' => true]).
  • Migrating bulk code: Use IDE find/replace React\HttpClient\ClientReact\Http\Browser, but always refactor request logic manually—don’t rely on mechanical replacements.
  • Test skipping: Integration tests hit httpbin.org. For offline work, run phpunit --exclude-group internet.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport