--- title: PHP | Stainless description: Generate production-ready PHP SDKs from your OpenAPI specification --- PHP is [fully supported](https://www.stainless.com/changelog/php-generator-general-availability). The Stainless PHP SDK generator creates idiomatic, type-safe PHP client libraries from your OpenAPI specification. **Example repositories:** - [anthropics/anthropic-sdk-php](https://github.com/anthropics/anthropic-sdk-php) - [browserbase/stagehand-php](https://github.com/browserbase/stagehand-php) - [dodopayments/dodopayments-php](https://github.com/dodopayments/dodopayments-php) ## Configuration To generate a PHP SDK, add the `php` target to your Stainless configuration file: ``` targets: php: package_name: Acme composer_package_name: acme-org/acme-php edition: php.2025-10-08 ``` ### Common configuration options ``` targets: php: # package_name is used within the SDK (e.g., class AcmeClient { ... }) package_name: Acme # composer_package_name is the Packagist installation name (e.g., composer require acme-org/acme-php) composer_package_name: acme-org/acme-php # Specify the edition edition: php.2025-10-08 # Configure publishing publish: packagist: true ``` For a complete list of configuration options, see the [PHP target reference](/docs/reference/config#php/index.md). ## Editions Editions allow Stainless to make improvements to SDKs that aren’t backwards-compatible. You can explicitly opt in to new editions when you’re ready. See the [SDK and config editions reference](/docs/reference/editions/index.md) for more information. #### php.2025-10-08 - Initial edition for PHP (used by default if no edition is specified) ## Publishing to Packagist Publish your PHP SDK to [Packagist](https://packagist.org/) for distribution. Before publishing, you need to [link a production repository](/docs/guides/publish#link-production-repos/index.md) where Stainless will push your SDK code. Set the Composer package name in the Stainless config Set `composer_package_name` **before** proceeding other steps. Navigate to the targets section of your stainless config, and ensure it resembles the following. ``` targets: php: package_name: acme composer_package_name: 'acme-org/acme-php' # <- Packagist installation name publish: packagist: true ``` The `composer_package_name` will appear in Packagist. Make sure that the name follows the [convention of the Composer specification](https://getcomposer.org/doc/04-schema.md#name), which is roughly equivalent to `vendor/package-name`. The `composer_package_name` name must be available on Packagist. The `package_name` is used **within the SDK**, e.g. to name the client `class AcmeClient { ... }`. The `packagist` name is used **by the ecosystem**, e.g. `composer require acme-org/acme-php`. Set up a Packagist account and package 1. Log in or sign up at [Packagist](https://packagist.org/). 2. Navigate into your profile by clicking on your username in the top right corner. 3. Navigate to the “Settings” section of your profile, and ensure your account is connected via GitHub. 4. Click the “Submit” button at the top and add your production GitHub repository, and follow the packagist instructions. Packagist requires that your production repository is public in order to publish packages. Private repositories are not supported for Packagist publishing. Find your Packagist “Safe API Token” 1. Ensuring you are signed in on Packagist, click on your username in the top right corner. 2. Ensure the sidebar is set to the “Profile” section. 3. Click the “Show Safe API Token” button, it is not necessary to use the “Main API Token”. Add secrets to your production repo 1. Ensure the Stainless GitHub app is installed in your production repo or your GitHub actions environment has your Stainless API Key. 2. In the production repo, navigate to **Secrets and variables** > **Actions** > **New repository secret**. The URL should look like `https://github.com///settings/secrets/actions/new`. 3. Add the following secrets: - `PACKAGIST_SAFE_KEY`: Your Packagist Safe API Token - `PACKAGIST_USERNAME`: Your username in Packagist as it appears in the top-right corner.