PHP Configuration Options

This section details the available configuration options for the PHP SDK. All configuration is managed in the gen.yaml file under the php section.

Version and General Configuration

php:
version: 1.2.3
packageName: "openapi/openapi"
namespace: "OpenAPI\\OpenAPI"
NameRequiredDefault ValueDescription
versiontrue0.0.1The current version of the SDK.
packageNametrueopenapi/openapiThe name of the composer package. See Composer Package Naming (opens in a new tab).
namespacetrueOpenAPI\\OpenAPIThe namespace for the package. See PHP Namespace Documentation (opens in a new tab).

Method and Paramater Management

php:
maxMethodParams: 4
NameRequiredDefault ValueDescription
maxMethodParamsfalse4Maximum number of parameters before an input object is created. 0 means input objects are always used.

Security Configuratiaon

php:
flattenGlobalSecurity: true
PropertyDescriptionTypeDefault
flattenGlobalSecurityEnables inline security credentials during SDK instantiation. Recommended: truebooleantrue

Import Management

php:
imports:
option: "openapi"
paths:
callbacks: models/Callbacks
errors: models/Errors
operations: models/Operations
shared: models/Components
webhooks: models/Webhooks
FieldRequiredDefault ValueDescription
optionfalse"openapi"Defines the type of import strategy. Typically set to "openapi", indicating that the structure is based on the OpenAPI document.
pathsfalse{}Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from.

Import Paths

ComponentDefault ValueDescription
callbacksmodels/callbacksThe directory where callback models will be imported from.
errorsmodels/errorsThe directory where error models will be imported from.
operationsmodels/operationsThe directory where operation models (i.e., API endpoints) will be imported from.
sharedmodels/componentsThe directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec.
webhooksmodels/webhooksThe directory for webhook models, if your SDK includes support for webhooks.

Error and Response Handling

php:
clientServerStatusCodesAsErrors: true
responseFormat: "flat"
enumFormat: "enum"
NameRequiredDefault ValueDescription
clientServerStatusCodesAsErrorsfalsetrueWhether to treat 4XX and 5XX status codes as errors.
responseFormatfalseflatDefines how responses are structured. Options: envelope, envelope-http, or flat.

Laravel Service Provider

If your PHP SDK is being used within a Laravel application, Speakeasy is able to generate the needed Service Provider (opens in a new tab) code to support seamless integration.

…all of Laravel’s core services, are bootstrapped via service providers.

But, what do we mean by “bootstrapped”? In general, we mean registering things, including registering service container bindings, event listeners, middleware, and even routes. Service providers are the central place to configure your application.

To enable the Laravel Service Provider generation, update the gen.yaml configuration setting enabled to true, and set svcName appropriately.

php:
laravelServiceProvider:
enabled: true
svcName: "openapi"
FieldRequiredDefault ValueDescription
laravelServiceProviderfalse{}Configure the genration of the Service Provider.

Laravel Service Provider Configuration

FieldRequiredDefault ValueDescription
enabledfalsefalseSet to tru to enable Service Provider generation.
svcNamefalse"openapi"The name to be used for the service provider.