Method
HttpClient::put
Send a PUT request with a body.
Description#
public HttpClient::put(
UriInterface|string $url,
mixed $requestData,
HttpClientOptions|array|null $options = null
): ResponseInterfaceTakes the body and the options like HttpClient::post.
Parameters#
- $url UriInterface|string
- The URL to put to
- $requestData mixed
- The body: a string, a stream, an array or an object
- $options HttpClientOptions|array|null = null
- Options for this request only
Return values#
ResponseInterface
Errors / Exceptions#
| Exception | When |
|---|---|
InvalidArgumentException | For an option name that does not exist |
RuntimeException | For a headers entry without a colon, and for array or object data with a Content-Type other than application/x-www-form-urlencoded or application/json |
Examples#
$response = $client->put('https://example.com/items/7', \json_encode(['name' => 'x']), [
'headers' => ['Content-Type: application/json'],
]);See also#
HttpClient::postSend a POST request with a body.HttpClient::requestSend a request with any method, a body and options for this request only.