@@ -190,8 +190,18 @@ return [
190190 | swap in a different adapter (e.g., `Http\Client\Curl\Client` from
191191 | `php-http/curl-client`, which you would need to install separately).
192192 |
193+ | To pass constructor arguments (timeouts, proxies, client options, etc.)
194+ | use the array form `[Class => [args]]`. Arguments are forwarded to the
195+ | adapter's constructor — it's on you to match its signature. Named args
196+ | are supported: `[Class => ['timeout' => 10]]`.
197+ |
193198 | Default: LaravelHttpClient::class
194199 |
200+ | Examples:
201+ | 'adapter' => LaravelHttpClient::class,
202+ | 'adapter' => [LaravelHttpClient::class => ['timeout' => 10, 'retry' => [3, 100]]],
203+ | 'adapter' => [Http\Client\Curl\Client::class => [null, null, [CURLOPT_PROXY => '...']]],
204+ |
195205 */
196206 'adapter' => LaravelHttpClient::class,
197207
@@ -221,14 +231,37 @@ By default we ship `Geocoder\Laravel\Http\LaravelHttpClient`, a thin PSR-18
221231 client that delegates every request to Laravel's ` Http ` facade. This means:
222232
223233- ` Http::fake() ` and ` Http::assertSent() ` work in your tests with no extra setup
224- - ` Http::timeout() ` , ` Http::retry() ` , ` Http::withMiddleware() ` , and any other
225- Laravel HTTP client configuration applies to geocoder requests
226234- One less third-party HTTP client to manage
227235
228- If you need a different transport, set ` 'adapter' ` in ` config/geocoder.php ` to
229- any class that implements ` Psr\Http\Client\ClientInterface ` . To go back to the
230- previous CURL adapter, install ` php-http/curl-client ` and set
231- ` 'adapter' => Http\Client\Curl\Client::class ` .
236+ #### Configuring Adapter Options
237+ You can pass constructor arguments to the adapter via the array form
238+ ` [Class => [args]] ` in ` config/geocoder.php ` . Arguments are forwarded directly
239+ to the adapter's constructor — it's on you to match its signature. Named
240+ arguments are supported.
241+
242+ The default ` LaravelHttpClient ` accepts ` timeout ` , ` connectTimeout ` , ` retry ` ,
243+ and ` options ` (Guzzle transport options). These are forwarded to the
244+ underlying Laravel ` PendingRequest ` :
245+ ``` php
246+ 'adapter' => [LaravelHttpClient::class => [
247+ 'timeout' => 10,
248+ 'connectTimeout' => 3,
249+ 'retry' => [3, 100], // [times, sleepMilliseconds]
250+ 'options' => ['verify' => false], // Guzzle transport options
251+ ]],
252+ ```
253+
254+ #### Using a Different Transport
255+ Set ` 'adapter' ` to any class that implements ` Psr\Http\Client\ClientInterface ` .
256+ To go back to the previous CURL adapter, install ` php-http/curl-client ` and
257+ pass your CURL options the same way:
258+ ``` php
259+ 'adapter' => [Http\Client\Curl\Client::class => [
260+ null,
261+ null,
262+ [CURLOPT_PROXY => env('CURL_PROXY'), CURLOPT_PROXYUSERPWD => env('CURL_PROXYUSERPWD')],
263+ ]],
264+ ```
232265
233266### Customization
234267If you would like to make changes to the default configuration, publish and
0 commit comments