The HttpClient package gives Quantum a small native cURL wrapper for outbound HTTP calls.
Use it when you want to:
- send one HTTP request and inspect its response body, headers, cookies, or cURL info
- batch multiple requests through native multi-cURL
- keep request setup in Quantum code without talking to raw cURL resources
This package is intentionally small. It does not add retries, middleware, authentication helpers, or response object mapping. You work with one HttpClient facade backed by Quantum-owned cURL adapters.
The package is built from three pieces:
Quantum\HttpClient\HttpClientis the runtime wrapperQuantum\HttpClient\Factories\HttpClientFactorycreates fresh request facadeshttpRequest(),httpMultiRequest(), andhttpAsyncMultiRequest()are helper shortcutsQuantum\HttpClient\Exceptions\HttpClientExceptionreports package-specific misuse such as starting before creating a requestQuantum\HttpClient\Enums\ExceptionMessagesdefines local message constants
The package supports three modes.
createRequest($url) creates a native CurlAdapter, stores the URL, and lets you configure the request through HttpClient methods plus supported adapter passthrough methods.
This is the only mode that supports:
setMethod()setData()getRequestHeaders()getResponseHeaders()getResponseCookies()getResponseBody()info()url()
createMultiRequest() creates a native MultiCurlAdapter and registers a completion callback that collects each finished response into the package's internal response store.
Use this when you want to queue several requests and read the aggregated responses after start() finishes.
createAsyncMultiRequest($success, $error) creates a native MultiCurlAdapter, wires your success and error callbacks, and also keeps Quantum's internal response and error stores populated.
Use this when your application wants callback handling while still allowing later inspection through getResponse() and getErrors().
setMethod() only accepts these values:
GETPOSTPUTPATCHDELETE
Any other method triggers HttpClientException::requestMethodNotAvailable(...).
Responses are stored in three sections:
headerscookiesbody
Headers are normalized to lowercase before storage, so Content-Type becomes content-type when you read it back.
For a single request, getResponse() returns one response array.
For multi requests, getResponse() returns a map keyed by curl request ID.
- You must call one of the
create...Request()methods before callingstart()or any adapter passthrough method. - Single-request inspection methods are not available for multi-request adapters.
setData()only affects the single-requeststart()path.- Request headers are only mirrored into
getRequestHeaders()when you set them through proxiedsetHeader()orsetHeaders()calls. - Reusing one
HttpClientinstance across multiple requests keeps prior wrapper state unless you overwrite it. That includes the current method, pending data, tracked request headers, and collected response/error arrays. - Adapter passthrough is intentionally limited to supported adapter methods such as
setHeader(),setHeaders(),setOpt(),setOpts(),addGet(), andaddPost().