Method
HttpClient::__construct
Create a client whose options are the defaults for every request it sends.
Description#
public HttpClient::__construct(
HttpClientOptions|array $defaultRequestOptions = []
)Parameters#
- $defaultRequestOptions HttpClientOptions|array = []
- Option values keyed by
HttpClientOptionsproperty name
Errors / Exceptions#
| Exception | When |
|---|---|
InvalidArgumentException | For an option name that does not exist |
Examples#
$client = new HttpClient([
'userAgent' => 'my-app/1.0',
'timeoutMs' => 5000,
'maxRedirs' => 5,
]);See also#
HttpClientOptionsThe options of an HTTP request, as public properties that map to cURL options.