v3.1.0
Added
-
PSR-18 Client:
Fetch\Http\Clientnow implementsPsr\Http\Client\ClientInterfacefor drop-in interoperability. -
Fluent Request Builder: Chainable helpers on
ClientHandlerfor headers, query params, JSON/form/multipart bodies, bearer token, basic auth, timeouts, redirects, cookies, proxy, certificates. -
Async/Promise Support: Built-in ReactPHP-style promises (
async(),await(),all(),race(),any(),sequence()), with->async()toggle andwrapAsync()/awaitPromise()helpers. -
Automatic Retries: Configurable max retries, retry delay, exponential backoff with jitter, and retry-on-status (408, 429, 5xx) or exceptions (
ConnectException). -
PSR-3 Logging: Optional
LoggerInterfaceinjection onClientandClientHandlerwith info/debug/error logs and sensitive-data masking for retries, requests, and responses. -
Immutable PSR-7 Extensions:
Fetch\Http\Requestextends Guzzle’s PSR-7Requestwith immutability traits and JSON/form/multipart constructors.Fetch\Http\Responseextends Guzzle’s PSR-7Responsewith buffered body, array-access to JSON payloads, and helpers:->json(),->text(),->xml(),->blob(),->arrayBuffer(), status inspectors, etc.
-
Enums for Safety:
Fetch\Enum\Method,ContentType, andStatusenums for validating methods, content types, and status codes. -
Test Helpers:
ClientHandler::createMockResponse()andcreateJsonResponse()to easily stub HTTP responses in unit tests.
Changed
- Consolidated Handler Traits: Core behavior refactored into six concerns (
ConfiguresRequests,HandlesUris,ManagesPromises,ManagesRetries,PerformsHttpRequests,SendsRequests) for clearer separation of URI handling, retries, promises, and request dispatch. - Unified Fetch API:
Client::fetch()now returns either aResponseInterfaceor the handler for method chaining, replacing older ad-hoc patterns. - Error-handling Alignment: Top-level
Client::sendRequest()now throws standardizedNetworkException,RequestException, orClientExceptioninstead of rawRuntimeException. - Default Options Management: Moved default method, headers, and timeout into
ClientHandler::$defaultOptionswith newgetDefaultOptions()andsetDefaultOptions(). - Guzzle Configuration:
ClientHandlernow reuses a single Guzzle client instance withRequestOptions::HTTP_ERRORSdisabled (handling errors internally) andCONNECT_TIMEOUTmapped from handler timeout.