Learn how to configure your private composer packages' billing, licensing, and distribution.
This guide will take a step-by-step approach to configuring billing, licensing, and distribution for your PHP composer packages via a private repository.
Let's start by creating your product. From your dashboard, click on "Add Product." Next, fill in the form with the following information:
You can choose to configure your first licensing policy and distribution now or later. Let's keep these options enabled and continue to the next step.
Before creating a new license, a licensing policy must be available. A policy is a set of rules that applies to a license. For example, the duration a license is valid or how many times a customer can use a license. Let's take a look at the available policy options:
Anystack makes distribution a joy by integrating with your existing stack. Connect your GitHub account, connect your private GitHub repositories, and create a new release, and that's it. Anystack will automatically import the files from your private repositories, and make these private packages available for distribution to your customers.
Let's connect our GitHub account and select the repository that holds our private package:
Now that your product has been set up, we can create our first release. Ensure the root of your repository contains a valid composer.json
.
There are several ways to do this:
In this example, we will use a GitHub action workflow to automatically create a release every time a new tag is
created. Optionally, you can create a custom distribution build as shown in the .github/workflows/release.yml
file below as option 2.
1name: Build release 2 3# Run this workflow when a tag is published that follows the semantic versioning schema. 4on: 5 push: 6 tags: 7 - "*.*.*" 8 9jobs:10 11 # ---------------------------------------------------------------------------12 # Option 113 # The following example will show you how to create a release with just14 # the source code from your repository15 # ---------------------------------------------------------------------------16 17 build:18 runs-on: ubuntu-latest19 steps:20 21 # Create a new release and use the source code from the tag for this release22 - name: Release and publish release23 uses: softprops/action-gh-release@v124 25 # That's it! All done 🚀26 27 # ---------------------------------------------------------------------------28 # Option 229 # The following example will show you how to create a custom distribution30 # build of your package31 # ---------------------------------------------------------------------------32 33 build:34 runs-on: ubuntu-latest35 steps:36 37 # Checkout the code of this repository38 - name: Checkout39 uses: actions/checkout@v240 41 # Setup PHP 8.042 - name: Setup PHP43 uses: shivammathur/setup-php@master44 with:45 php-version: 8.046 47 # Install the composer dependencies48 - name: Install Dependencies49 run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist50 51 # Create a zip archive of all the files and exclude certain files from the archieve52 - name: Create release archive53 uses: thedoctor0/zip-release@master54 with:55 type: 'zip'56 filename: 'release.zip'57 exclusions: '*.git* /*node_modules/* .editorconfig'58 59 # Create a new release and include the build artifact from the previous step60 - name: Release and publish release61 uses: softprops/action-gh-release@v162 with:63 files: release.zip
Publish a new tag, and you will see a new release created automatically and show up on your dashboard in a matter of seconds.
Perfect! We have our licensing policy set up; our release has been imported and published. Let's continue by setting up billing so we can sell our package. Choose billing from your product navigation.
Anystack partners with Stripe to provide the best checkout experience there is. Click "Start Selling" to start the onboarding process with Stripe. Once you're done, you can configure the billing settings for your product.
From the billing page, you can enable billing for your product, create pricing packages, enable tax collection, manage license settings and upload an image that Anystack will show during checkout. Let's continue by creating our first pricing package.
There are a few more additional settings you can configure regarding billing. Let's take a look.
When a customer purchases your product, Anystack will generate a license key for your customer. The license key is the personal access token to authorize access to the private repository. If your policy requires a fingerprint (activation), the following options can be configured to allow the customer to activate or revoke their license themselves.
On the purchase page, we will show the image you upload. You could use this to upload a screenshot of your application, for example:
That's it; you are all set and ready to sell your private PHP package. Anystack will show your customers the installation instructions on adding your private composer repository and requiring your private PHP package.
composer init
- this command will prompt all the necessary questions to generate a valid composer json file.
http-basic
authentication. The username is equal to the contact's email, and the password is equal to the license key. If the license is not associated with any contact, the username is unlock
.