Learn how to switch between different HTTP client implementations using the Instructor HTTP client API.
GuzzleDriver
provides integration with the popular Guzzle HTTP client.
Key Features:
guzzlehttp/guzzle
package (composer require guzzlehttp/guzzle
)SymfonyDriver
integrates with the Symfony HTTP Client.
Key Features:
symfony/http-client
package (composer require symfony/http-client
)LaravelDriver
integrates with the Laravel HTTP Client.
Key Features:
MockHttpDriver
is a test double that doesn’t make actual HTTP requests but returns predefined responses.
Key Features:
HttpClient
instance:
config/http.php
file.
config/http.php
file:
HttpClient
class provides a static make
method as an alternative to the constructor:
config/http.php
file:
Parameter | Type | Description |
---|---|---|
httpClientType | string | The type of HTTP client (Guzzle, Symfony, Laravel) |
connectTimeout | int | Maximum time to wait for connection establishment (seconds) |
requestTimeout | int | Maximum time to wait for the entire request (seconds) |
idleTimeout | int | Maximum time to wait between data packets (seconds, -1 for no timeout) |
maxConcurrent | int | Maximum number of concurrent requests in a pool |
poolTimeout | int | Maximum time to wait for all pooled requests (seconds) |
failOnError | bool | Whether to throw exceptions for HTTP error responses |
verify
(for SSL verification) or proxy
settings that can be passed through the underlying client.