Method
HttpClient::get
Send a GET request.
Description#
public HttpClient::get(
UriInterface|string $url,
HttpClientOptions|array|null $options = null
): ResponseInterfaceTo send data in the query string, put it in the URL or use request('GET', $url, $data).
Parameters#
- $url UriInterface|string
- The URL to fetch
- $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 |
Examples#
$response = $client->get('https://example.com/search?q=phasync', ['timeoutMs' => 2000]);
$data = \json_decode((string) $response->getBody(), true);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.