Documentation

GuzzleHttp

Table of Contents

Namespaces

Cookie
Exception
Handler
Promise
Psr7

Interfaces

BodySummarizerInterface
ClientInterface
Client interface for sending HTTP requests.
MessageFormatterInterface

Classes

BodySummarizer
Client
HandlerStack
Creates a composed Guzzle handler function by stacking middlewares on top of an HTTP handler function.
MessageFormatter
Formats log messages using variable substitutions for requests, responses, and other transactional data.
Middleware
Functions used to create and wrap handlers with handler middleware.
Pool
Sends an iterator of requests concurrently using a capped pool size.
PrepareBodyMiddleware
Prepares requests that contain a body, adding the Content-Length, Content-Type, and Expect headers.
RedirectMiddleware
Request redirect middleware.
RequestOptions
This class contains a list of built-in Guzzle request options.
RetryMiddleware
Middleware that retries requests based on the boolean result of invoking the provided "decider" function.
TransferStats
Represents data at the point after it was transferred either successfully or after a network error.
Utils

Traits

ClientTrait
Client interface for sending HTTP requests.

Functions

describe_type()  : string
Debug function used to describe the provided value type and class.
headers_from_lines()  : array<string|int, mixed>
Parses an array of header lines into an associative array of headers.
debug_resource()  : resource
Returns a debug stream based on the provided variable.
choose_handler()  : callable
Chooses and creates a default handler to use based on the environment.
default_user_agent()  : string
Get the default User-Agent string to use with Guzzle.
default_ca_bundle()  : string
Returns the default cacert bundle for the current system.
normalize_header_keys()  : array<string|int, mixed>
Creates an associative array of lowercase header names to the actual header casing.
is_host_in_noproxy()  : bool
Returns true if the provided host matches any of the no proxy areas.
json_decode()  : object|array<string|int, mixed>|string|int|float|bool|null
Wrapper for json_decode that throws when an error occurs.
json_encode()  : string
Wrapper for JSON encoding that throws when an error occurs.

Functions

describe_type()

Debug function used to describe the provided value type and class.

describe_type(mixed $input) : string
Parameters
$input : mixed

Any type of variable to describe the type of. This parameter misses a typehint because of that.

Tags
deprecated

describe_type will be removed in guzzlehttp/guzzle:8.0. Use Utils::describeType instead.

Return values
string

Returns a string containing the type of the variable and if a class is provided, the class name.

headers_from_lines()

Parses an array of header lines into an associative array of headers.

headers_from_lines(iterable<string|int, mixed> $lines) : array<string|int, mixed>
Parameters
$lines : iterable<string|int, mixed>

Header lines array of strings in the following format: "Name: Value"

Tags
deprecated

headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead.

Return values
array<string|int, mixed>

debug_resource()

Returns a debug stream based on the provided variable.

debug_resource([mixed $value = null ]) : resource
Parameters
$value : mixed = null

Optional value

Tags
deprecated

debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead.

Return values
resource

choose_handler()

Chooses and creates a default handler to use based on the environment.

choose_handler() : callable

The returned handler is not wrapped by any default middlewares.

Tags
throws
RuntimeException

if no viable Handler is available.

deprecated

choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.

Return values
callable

\GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.

default_user_agent()

Get the default User-Agent string to use with Guzzle.

default_user_agent() : string
Tags
deprecated

default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead.

Return values
string

default_ca_bundle()

Returns the default cacert bundle for the current system.

default_ca_bundle() : string

First, the openssl.cafile and curl.cainfo php.ini settings are checked. If those settings are not configured, then the common locations for bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X and Windows are checked. If any of these file locations are found on disk, they will be utilized.

Note: the result of this function is cached for subsequent calls.

Tags
throws
RuntimeException

if no bundle can be found.

deprecated

default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+.

Return values
string

normalize_header_keys()

Creates an associative array of lowercase header names to the actual header casing.

normalize_header_keys(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
$headers : array<string|int, mixed>
Tags
deprecated

normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead.

Return values
array<string|int, mixed>

is_host_in_noproxy()

Returns true if the provided host matches any of the no proxy areas.

is_host_in_noproxy(string $host, array<string|int, string> $noProxyArray) : bool

This method will strip a port from the host if it is present. Each pattern can be matched with an exact match (e.g., "foo.com" == "foo.com") or a partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" == "baz.foo.com", but ".foo.com" != "foo.com").

Areas are matched in the following cases:

  1. "*" (without quotes) always matches any hosts.
  2. An exact match.
  3. The area starts with "." and the area is the last part of the host. e.g. '.mit.edu' will match any host that ends with '.mit.edu'.
Parameters
$host : string

Host to check against the patterns.

$noProxyArray : array<string|int, string>

An array of host patterns.

Tags
throws
InvalidArgumentException
deprecated

is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead.

Return values
bool

json_decode()

Wrapper for json_decode that throws when an error occurs.

json_decode(string $json[, bool $assoc = false ][, int $depth = 512 ][, int $options = 0 ]) : object|array<string|int, mixed>|string|int|float|bool|null
Parameters
$json : string

JSON data to parse

$assoc : bool = false

When true, returned objects will be converted into associative arrays.

$depth : int = 512

User specified recursion depth.

$options : int = 0

Bitmask of JSON decode options.

Tags
throws
InvalidArgumentException

if the JSON cannot be decoded.

see
https://www.php.net/manual/en/function.json-decode.php
deprecated

json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.

Return values
object|array<string|int, mixed>|string|int|float|bool|null

json_encode()

Wrapper for JSON encoding that throws when an error occurs.

json_encode(mixed $value[, int $options = 0 ][, int $depth = 512 ]) : string
Parameters
$value : mixed

The value being encoded

$options : int = 0

JSON encode option bitmask

$depth : int = 512

Set the maximum depth. Must be greater than zero.

Tags
throws
InvalidArgumentException

if the JSON cannot be encoded.

see
https://www.php.net/manual/en/function.json-encode.php
deprecated

json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead.

Return values
string

        
On this page

Search results