php-openapi-generator

HTTP Client Adapters

For GenerationTarget::Client, the generator emits typed API clients with one of three HTTP transport styles.

Overview

Adapter Constructor Dependencies Request Method Good Choice For
HttpClientAdapter::SymfonyHttpClient Symfony\Contracts\HttpClient\HttpClientInterface request() Symfony apps and lightweight clients
HttpClientAdapter::Guzzle GuzzleHttp\ClientInterface request() + RequestOptions Existing Guzzle middleware stacks
HttpClientAdapter::Psr18 Psr\Http\Client\ClientInterface, request factory, stream factory sendRequest() Portable libraries and framework-neutral code

All adapters expose the same generated API signatures (*ApiClientInterface + *ApiClient).

Generated Files

generated/
|- Api/
|  |- PetsApiClientInterface.php
|  `- PetsApiClient.php
`- Model/
   |- Pet.php
   |- NewPet.php
   `- ...

Shared Runtime Behavior

Typical Configuration

use MaxBeckers\OpenApiGenerator\Config\GenerationTarget;
use MaxBeckers\OpenApiGenerator\Config\HttpClientAdapter;

$config->generationTarget = GenerationTarget::Client;
$config->httpClient = HttpClientAdapter::SymfonyHttpClient; // symfony|guzzle|psr18
$config->httpClientVersion = '7.0'; // optional, when adapter majors require different generated code

Leave $config->httpClientVersion as null if you do not need adapter-version-specific generation yet.

Adapter-Specific Guides