phasync
HttpClient / get

Method

HttpClient::get

Send a GET request.

Description#

public HttpClient::get(
    UriInterface|string $url,
    HttpClientOptions|array|null $options = null
): ResponseInterface

To 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#

ExceptionWhen
InvalidArgumentExceptionFor an option name that does not exist
RuntimeExceptionFor a headers entry without a colon

Examples#

Example 1
$response = $client->get('https://example.com/search?q=phasync', ['timeoutMs' => 2000]);
$data     = \json_decode((string) $response->getBody(), true);

See also#