Available Drivers
The package ships with three production drivers and one test driver:| Driver name | Library | Package |
|---|---|---|
curl | PHP cURL extension | Built-in (no dependency) |
guzzle | Guzzle HTTP | guzzlehttp/guzzle |
symfony | Symfony HttpClient | symfony/http-client |
| (mock) | Built-in test double | Built-in |
curl, which requires no additional dependencies since the cURL extension is included with most PHP installations.
CurlDriver
The cURL driver provides zero-dependency HTTP support. It uses PHP’s native cURL extension with automatic HTTP/1.1 and HTTP/2 negotiation, full header parsing, streaming support, and built-in SSL verification. This is the best choice for quick starts and lightweight applications.GuzzleDriver
Guzzle is a mature, feature-rich HTTP client with its own middleware ecosystem, PSR-7 message support, and excellent streaming capabilities. Use it when you need Guzzle-specific features or when your project already depends on it.SymfonyDriver
The Symfony HttpClient offers native HTTP/2 support, automatic content-type detection, and multiple transports (native PHP, cURL, amphp). It is the natural choice for Symfony applications.Switching Drivers
Via Configuration
The simplest way to choose a driver is throughHttpClientConfig:
Via the Builder
The builder gives you the same choice in a more explicit, composable form:Injecting a Driver Directly
If you have a pre-configured driver instance, bypass the registry entirely:Reusing a Vendor Client Instance
Sometimes you already have a configured vendor client (e.g., aGuzzleHttp\Client with custom options or a Symfony client with specific transport settings). You can pass that instance directly:
withClientInstance() method selects the driver by name and passes your vendor client to it, so the driver uses your instance instead of creating its own.
This works with any supported driver:
Using the Mock Driver
For testing, the mock driver lets you define responses without making network calls:Request Code Stays the Same
The key insight is that your request code never changes when you switch drivers. The sameHttpRequest, the same send() call, the same response handling:
See Also
- Changing Client Config — configure timeouts, error handling, and stream settings.
- Custom Clients — register your own driver when the bundled ones are not enough.