> This page is for SDKs, version Legacy.
> For other versions, use one of these documentation indexes:
> - Current (default): https://buildwithfern.com/learn/sdks/current/llms.txt
> - Legacy: https://buildwithfern.com/learn/sdks/legacy/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

# Publishing to Packagist

> How to publish the Fern PHP SDK to Packagist.

> **You're viewing the legacy SDK docs**
>
> These pages cover SDK generation configured with `generators.yml`. New projects use `sdk-config.yml`, so see [the Current version of this page](/learn/sdks/generators/php/publishing) for up-to-date guidance. To move an existing project, follow the [SDK Config migration guide](/learn/sdks/legacy/generators/migration-guides/sdk-config), which walks through `fern sdk migrate`, and review the [`sdk-config.yml` reference](/learn/sdks/reference/sdk-config).

> **Enterprise feature**
>
> This feature is available only for the [Enterprise plan](https://buildwithfern.com/pricing). To get started, reach out to [support@buildwithfern.com](mailto:support@buildwithfern.com).

Publish your public-facing Fern PHP SDK to the [Packagist registry](https://packagist.org/). After following the steps on this page,
you'll have a versioned package published on Packagist. To distribute the SDK
internally instead, generate to the local file system (optionally
[self-hosted](/learn/sdks/legacy/deep-dives/self-hosted)) and build a Composer archive
with [`fern generate --package`](/learn/cli-api-reference/cli-reference/sdk-commands#package).

> **Info**
>
> This page assumes that you have:
>
> * An initialized `fern` folder, a GitHub repository for your PHP SDK, and a PHP generator group in `generators.yml`. See [Generating an SDK (PHP)](/learn/sdks/legacy/generators/php/quickstart).

![Versioned package published on Packagist](/learn/_fern-img/95d33575f74173e5e7494a8b19315d6e267b4e09c50ee55644686f6741e4a1fd.webp)

## Configure `generators.yml`

#### Add repository location

PHP publishes via Git repositories, so remove the auto-generated `output`, `location`, and `path` fields. Instead, add the path to your GitHub repository:

```yaml {6-7}
groups: 
  php-sdk:
    generators:
      - name: fern-php-sdk
        version: 4.23.2
        github: 
          repository: your-org/company-php
```

## Set up Packagist publishing authentication

#### Log into Packagist

Log into [Packagist](https://packagist.org/login/) or [create an account with Packagist](https://packagist.org/register/).

#### Submit the Repository URL

1. Click **Submit**.
2. Input the full URL of the repository where you generated your PHP SDK, then click **Check**.
3. Fix any errors Packagist finds in your repository, then click **Submit**.

![Submit Package Screen in Packagist](/learn/_fern-img/535709461a584f985bebf2cf4227e351699f20eaa77a131b6f6dce4758ddb6fc.webp)

#### Configure the GitHub Hook

Once you've submitted your URL, you'll be prompted to set up the GitHub Hook.

1. In to your repository, go to **Settings > Webhooks**.
2. Select **"Add webhook"**
3. Set the Payload URL as `https://packagist.org/api/github?username=<your.packagist.username>`
4. Set the content type as `application/json`
5. Packagist autogenerates API Tokens. To find yours, go to your **Profile**. Then, add your token to the **Secret** field.
6. Set the trigger events as **Just the `push` event**
7. Click **"Add Webhook"**

![GitHub Webhook for Packagist](/learn/_fern-img/e8f5fa05931ee68cd8cd1fa2957a22987c4153e645672279341f8c02eaad907b.webp)

## Release your SDK to Packagist

At this point, you're ready to regenerate your SDK and publish it on Packagist:

```bash
fern generate --group php-sdk --version <version>
```

Local machine output will verify that the release is pushed to your
repository and tagged with the version you specified. Log back into Packagist, click on your username, and select **My packages** to see your new release.