forked from geocoder-php/Geocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added info how to configure the HTTP client
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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 [Guzzle6 client](https://github.com/guzzle/guzzle) and one with the | ||
[cURL client](https://github.com/php-http/curl-client). | ||
|
||
## Guzzle6 | ||
|
||
```php | ||
use GuzzleHttp\Client as GuzzleClient; | ||
use Http\Adapter\Guzzle6\Client; | ||
use Geocoder\Provider\GoogleMaps; | ||
|
||
$config = [ | ||
'timeout' => 2.0, | ||
'verify' => false, | ||
]; | ||
$guzzle = new GuzzleClient($config); | ||
|
||
$adapter = new Client($guzzle); | ||
$geocoder = new GoogleMaps($adapter); | ||
|
||
$geocoder->geocode(...); | ||
``` | ||
|
||
|
||
## cURL | ||
|
||
```php | ||
use Http\Client\Curl\Client; | ||
use Geocoder\Provider\GoogleMaps; | ||
|
||
$options = [ | ||
CURLOPT_CONNECTTIMEOUT => 2, | ||
CURLOPT_SSL_VERIFYPEER => false, | ||
]; | ||
|
||
$adapter = new Client(null, null, $options); | ||
$geocoder = new GoogleMaps($adapter); | ||
|
||
$geocoder->geocode(...); | ||
``` | ||
|