Publish PHP SDKs manually
This guide covers publishing PHP SDKs manually. For information on automating PHP SDK publishing, see Publish PHP SDKs automatically.
To share your generated PHP SDK with the community, you can publish it to Packagist. This enables other developers to install it using composer require.
Prerequisites
To publish your SDK to Packagist, you need the following:
- A public Git repository (for example, GitHub or GitLab).
- A Packagist account.
- A valid
composer.jsonwith anamefield invendor/packageformat.
Initial setup
-
Push your SDK to a public repository.
-
Sign in to Packagist and click Submit.
-
Enter your repository URL and submit. Packagist validates your
composer.jsonand creates the package listing. -
Configure a GitHub webhook so Packagist automatically picks up new versions. In your repository settings, follow the instructions shown on your Packagist package page under Set up GitHub Hook.
Configure composer.json
Your SDK’s composer.json should include the following fields for a proper Packagist listing:
Publish your PHP SDK to Packagist
To publish your SDK, do the following:
-
Tag a release using semantic versioning.
-
Packagist picks up the tag automatically if the webhook is configured. Otherwise, trigger a manual update from your package page.
-
Verify the publication at
https://packagist.org/packages/your-vendor/your-sdk.
Publish updates
To publish updates to your SDK, do the following:
Best practices for publishing PHP SDKs
Use the following best practices when publishing your PHP SDK to Packagist:
- Use semantic versioning.
- Include a comprehensive
README.mdwith installation and usage instructions. - Tag releases in Git rather than relying on branch-based version constraints.
- Declare a specific PHP version constraint in
composer.json(for example,"php": "^8.1"). - Run your test suite before tagging a release.