Use this adapter when your application standardizes on Guzzle.
$config->generationTarget = GenerationTarget::Client;
$config->httpClient = HttpClientAdapter::Guzzle;
$config->httpClientVersion = '7.8';
public function __construct(
private readonly ClientInterface $httpClient,
private readonly string $baseUrl,
) {
}
$options = [];
$options[RequestOptions::QUERY] = $query;
$options[RequestOptions::JSON] = $body->toArray();
$response = $this->httpClient->request('PUT', $this->baseUrl . "/pets/{$petId}", $options);
The generated code decodes response JSON explicitly:
$data = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR);
Then maps the payload to generated models via fromArray().
RequestOptions constants for predictable option names.