Cmd/Ctrl + K

HTTP client

Annabel exposes a lightweight HTTP client through http_client().

Usage

Resolve the configured client through the helper for application HTTP requests.

The default transport uses PHP streams. Custom transports are useful for tests or advanced integrations.

Requests

Use the convenience methods for common verbs or build a request with explicit options.

Array request bodies are JSON-encoded and receive Content-Type: application/json unless a content type header is already set.

Responses

Inspect the response status, headers, raw body, or decoded JSON data.

throw() raises an HTTP client exception for responses with status 400 or higher.

Custom transport

Inject a custom transport when you need deterministic tests:

The transport must implement Codemonster\HttpClient\Contracts\TransportInterface.