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.3packageName: "openapi/openapi"namespace: "OpenAPI\\OpenAPI"
Name | Required | Default Value | Description |
---|---|---|---|
version | true | 0.0.1 | The current version of the SDK. |
packageName | true | openapi/openapi | The name of the composer package. See Composer Package Naming (opens in a new tab). |
namespace | true | OpenAPI\\OpenAPI | The namespace for the package. See PHP Namespace Documentation (opens in a new tab). |
Method and Paramater Management
php:maxMethodParams: 4
Name | Required | Default Value | Description |
---|---|---|---|
maxMethodParams | false | 4 | Maximum number of parameters before an input object is created. 0 means input objects are always used. |
Security Configuratiaon
php:flattenGlobalSecurity: true
Property | Description | Type | Default |
---|---|---|---|
flattenGlobalSecurity | Enables inline security credentials during SDK instantiation. Recommended: true | boolean | true |
Import Management
php:imports:option: "openapi"paths:callbacks: models/Callbackserrors: models/Errorsoperations: models/Operationsshared: models/Componentswebhooks: models/Webhooks
Field | Required | Default Value | Description |
---|---|---|---|
option | false | "openapi" | Defines the type of import strategy. Typically set to "openapi" , indicating that the structure is based on the OpenAPI document. |
paths | false | {} | Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from. |
Import Paths
Component | Default Value | Description |
---|---|---|
callbacks | models/callbacks | The directory where callback models will be imported from. |
errors | models/errors | The directory where error models will be imported from. |
operations | models/operations | The directory where operation models (i.e., API endpoints) will be imported from. |
shared | models/components | The directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec. |
webhooks | models/webhooks | The directory for webhook models, if your SDK includes support for webhooks. |
Error and Response Handling
php:clientServerStatusCodesAsErrors: trueresponseFormat: "flat"enumFormat: "enum"
Name | Required | Default Value | Description |
---|---|---|---|
clientServerStatusCodesAsErrors | false | true | Whether to treat 4XX and 5XX status codes as errors. |
responseFormat | false | flat | Defines 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: truesvcName: "openapi"
Field | Required | Default Value | Description |
---|---|---|---|
laravelServiceProvider | false | {} | Configure the generation of the Service Provider. |
Laravel Service Provider Configuration
Field | Required | Default Value | Description |
---|---|---|---|
enabled | false | false | Set to true to enable Service Provider generation. |
svcName | false | "openapi" | The name to be used for the service provider. |
Additional Dependencies
php:additionalDependencies: {"autoload": {"OpenAPI\\OpenAPI\\Lib\\": "lib/"},"autoload-dev": {"OpenAPI\\OpenAPI\\Test\\": "Tests/"},"require": {"firebase/php-jwt": "^6.10","phpseclib/phpseclib": "^3.0"},"require-dev": {"monolog/monolog": "^3.0"}}
Field | Required | Default Value | Description |
---|---|---|---|
additionalDependencies | false | {} | Specify additional dependencies and autoload mappings to include in the generated composer.json file. |
Additional Dependencies Configuration
Name | Required | Default Value | Description |
---|---|---|---|
autoload | false | {} | Autoload mappings to be included in the autoload.psr4 section. |
autoload-dev | false | {} | Autoload mappings to be included in the autoload-dev.psr4 section (for development and testing). |
require | false | {} | Additional dependencies to be included in the require section. |
require-dev | false | {} | Additional dependencies to be included in the require-dev section (for development and testing). |