Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1022 Bytes

http-client.md

File metadata and controls

44 lines (31 loc) · 1022 Bytes

Configuring the HTTP client

The Geocoder is decoupled from the HTTP client that sends the HTTP messages. This means that you are responsible for configuring the HTTP client. Usually the default configuration is good enough but sometime you may want to do something differently.

How you configure the client differs between different clients below are two examples, one with Guzzle 7 client and one with the cURL client.

Guzzle 7

use GuzzleHttp\Client;
use Geocoder\Provider\GoogleMaps;

$config = [
    'timeout' => 2.0,
    'verify' => false,
];

$client = new Client($config);
$geocoder = new GoogleMaps($client);

$geocoder->geocode(...);

cURL

use Http\Client\Curl\Client;
use Geocoder\Provider\GoogleMaps;

$options = [
    CURLOPT_CONNECTTIMEOUT => 2,
    CURLOPT_SSL_VERIFYPEER => false,
];

$client  = new Client(null, null, $options);
$geocoder = new GoogleMaps($client);

$geocoder->geocode(...);