You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/sdks/overview/php/publishing-to-packagist.mdx
+120-2Lines changed: 120 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,124 @@ title: Publishing to Packagist
3
3
description: How to publish the Fern PHP SDK to Packagist.
4
4
---
5
5
6
-
Learn how to publish your Fern PHP SDK to the Packagist registry.
6
+
Publish your public-facing Fern PHP SDK to the [Packagist
7
+
registry](https://packagist.org/). After following the steps on this page,
8
+
you'll have a versioned package published on Packagist.
7
9
8
-
<Warning>This page is a WIP, please refer to our previous [documentation](https://buildwithfern.com/learn/sdks/guides/publish-a-public-facing-sdk).</Warning>
10
+
<Frame>
11
+
<imgsrc="assets/packagist-package.png"alt="Versioned package published on Packagist" />
12
+
</Frame>
13
+
14
+
<Info>This guide assumes that you already have an initialized `fern` folder on your local machine. If you don’t, run `fern init`. See [PHP Quickstart](quickstart.mdx) for more details.</Info>
15
+
16
+
## Set up your GitHub integration
17
+
18
+
1. Create a new GitHub repository called `company-php` (or something similar) for your SDK, if you haven't done so already.
19
+
<Warning>
20
+
Your repository must:
21
+
* Have **public** visibility. You can configure this in your repository's
22
+
**Settings**.
23
+
* Have a `composer.json` file in your main branch that adheres to Packagist's
1. Install the [Fern GitHub App](https://github.com/apps/fern-api): Select **Configure**, then scroll down to **Repository Access**. Select **Only select repositories** and in the dropdown select the repository for your SDK. Click **Save**.
29
+
30
+
31
+
## Configure `generators.yml`
32
+
33
+
<Steps>
34
+
35
+
<Steptitle="Run `fern add <generator>`">
36
+
37
+
Navigate to your `generators.yml` on your local machine. Your `generators.yml` lives inside of your `fern` folder and contains all the configuration for your Fern generators.
38
+
39
+
Add a new generator to `generators.yml`:
40
+
41
+
42
+
```bash
43
+
fern add fern-php-sdk --group php-sdk
44
+
```
45
+
46
+
Once the command completes, you'll see a new group created in your `generators.yml`:
PHP publishes via Git repositories, so remove the auto-generated `output`, `location`, and `path` fields. Instead, add the path to your GitHub repository:
Log into [Packagist](https://packagist.org/login/) or [create an account with Packagist](https://packagist.org/register/).
86
+
87
+
</Step>
88
+
<Step title="Submit the Repository URL">
89
+
90
+
1. Click **Submit**.
91
+
1. Input the full URL of the repository where you generated your PHP SDK, then click **Check**.
92
+
1. Fix any errors Packagist finds in your repository, then click **Submit**.
93
+
94
+
<Frame>
95
+
<img src="assets/submit-package.png" alt="Submit Package Screen in Packagist" />
96
+
</Frame>
97
+
98
+
</Step>
99
+
100
+
<Step title="Configure the GitHub Hook">
101
+
102
+
Once you've submitted your URL, you'll be prompted to set up the GitHub Hook.
103
+
104
+
1. In to your repository, go to **Settings > Webhooks**.
105
+
1. Select **"Add webhook"**
106
+
1. Set the Payload URL as `https://packagist.org/api/github?username=<your.packagist.username>`
107
+
1. Set the content type as `application/json`
108
+
1. Packagist autogenerates API Tokens. To find yours, go to your **Profile**. Then, add your token to the **Secret** field.
109
+
1. Set the trigger events as **Just the `push` event**
110
+
1. Click **"Add Webhook"**
111
+
<Frame>
112
+
<img src="assets/webhook.png" alt="GitHub Webhook for Packagist" />
113
+
</Frame>
114
+
</Step>
115
+
</Steps>
116
+
117
+
## Release your SDK to Packagist
118
+
119
+
At this point, you're ready to regenerate your SDK and publish it on Packagist:
120
+
121
+
```bash
122
+
fern generate --group php-sdk --version <version>
123
+
```
124
+
Local machine output will verify that the release is pushed to your
125
+
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.
0 commit comments