# PHP Configuration Options
Source: https://speakeasy.com/docs/speakeasy-reference/generation/php-config

import { Table } from "@/mdx/components";



 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

```yml
php:
  version: 1.2.3
  packageName: "openapi/openapi"
  namespace: "OpenAPI\\OpenAPI"
```

<Table 
  data={[
    { name: "version", required: "true", default: "0.0.1", description: "The current version of the SDK." },
    { name: "packageName", required: "true", default: "openapi/openapi", description: "The name of the composer package. See [Composer Package Naming](https://getcomposer.org/doc/04-schema.md#name)." },
    { name: "namespace", required: "true", default: "OpenAPI\\OpenAPI", description: "The namespace for the package. See [PHP Namespace Documentation](https://www.php.net/manual/en/language.namespaces.rationale.php)." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Method and parameter management
```yml
php:
  maxMethodParams: 4
```

<Table 
  data={[
    { name: "[maxMethodParams](/docs/customize/methods)", required: "false", default: "4", description: "Sets the maximum number of parameters before an input object is created. `0` means input objects are always used." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Security configuration

```yml
php:
  flattenGlobalSecurity: true
```

<Table 
  data={[
    { property: "[flattenGlobalSecurity](/docs/customize/authentication/overview)", description: "Enables inline security credentials during SDK instantiation. **Recommended: `true`**", type: "boolean", default: "true" }
  ]}
  columns={[
    { key: "property", header: "Property" },
    { key: "description", header: "Description" },
    { key: "type", header: "Type" },
    { key: "default", header: "Default" }
  ]}
/>

## Import management

```yml
php:
  imports:
    option: "openapi"
    paths:
      callbacks: models/Callbacks
      errors: models/Errors
      operations: models/Operations
      shared: models/Components
      webhooks: models/Webhooks
```

<Table 
  data={[
    { field: "option", required: "false", default: "\"openapi\"", description: "Defines the type of import strategy. Typically set to `\"openapi\"`, indicating that the structure is based on the OpenAPI document." },
    { field: "paths", required: "false", default: "{}", description: "Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from." }
  ]}
  columns={[
    { key: "field", header: "Field" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

### Import paths

<Table 
  data={[
    { component: "callbacks", default: "models/callbacks", description: "The directory where callback models will be imported from." },
    { component: "errors", default: "models/errors", description: "The directory where error models will be imported from." },
    { component: "operations", default: "models/operations", description: "The directory where operation models (i.e., API endpoints) will be imported from." },
    { component: "shared", default: "models/components", description: "The directory for shared components, such as reusable schemas, and data models imported from the OpenAPI spec." },
    { component: "webhooks", default: "models/webhooks", description: "The directory for webhook models, if the SDK includes support for webhooks." }
  ]}
  columns={[
    { key: "component", header: "Component" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Error and Response Handling

```yml
php:
  clientServerStatusCodesAsErrors: true
  responseFormat: "flat"
  enumFormat: "enum"
```

<Table 
  data={[
    { name: "clientServerStatusCodesAsErrors", required: "false", default: "true", description: "Whether to treat 4XX and 5XX status codes as errors." },
    { name: "[responseFormat](/docs/customize/responses/responses)", required: "false", default: "flat", description: "Defines how responses are structured. Options: `envelope`, `envelope-http`, or `flat`." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Laravel service provider

When a PHP SDK is used within a Laravel application, Speakeasy is able to generate the needed [Service Provider](https://laravel.com/docs/master/providers)
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 the application.

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

```yml
php:
  laravelServiceProvider:
    enabled: true
    svcName: "openapi"
```

<Table 
  data={[
    { field: "laravelServiceProvider", required: "false", default: "{}", description: "Configure the generation of the Service Provider." }
  ]}
  columns={[
    { key: "field", header: "Field" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

### Laravel service provider configuration

<Table 
  data={[
    { field: "enabled", required: "false", default: "false", description: "Set to true to enable Service Provider generation." },
    { field: "svcName", required: "false", default: "\"openapi\"", description: "The name to be used for the service provider." }
  ]}
  columns={[
    { key: "field", header: "Field" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

## Additional dependencies

```yml
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"
    }
  }
```

<Table 
  data={[
    { field: "additionalDependencies", required: "false", default: "{}", description: "Adds additional dependencies and autoload mappings to the generated `composer.json` file." }
  ]}
  columns={[
    { key: "field", header: "Field" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>

### Additional dependencies configuration

<Table 
  data={[
    { name: "autoload", required: "false", default: "{}", description: "Defines autoload mappings for the `autoload.psr4` section." },
    { name: "autoload-dev", required: "false", default: "{}", description: "Defines autoload mappings for the `autoload-dev.psr4` section (for development and testing)." },
    { name: "require", required: "false", default: "{}", description: "Adds additional dependencies to the `require` section." },
    { name: "require-dev", required: "false", default: "{}", description: "Adds additional dependencies to the `require-dev` section (for development and testing)." }
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" }
  ]}
/>