Currently Available: Need a skilled Software Developer for your next project?
Categories
Laravel

Selling Laravel Packages, Part 5: Distributing Private Packages with Satis

When you sell a Laravel package, your customers need a way to install it through Composer while you keep the source code private. Satis generates a static Composer repository, which is a set of files that tells Composer which package versions exist and where to download them.

Satis does not handle checkout, record purchases, or decide which customer has access. You connect it to your existing sales and account setup, then configure your hosting server to protect the repository and package downloads. Satis works well if you want to run your own package repository and give customers access to a shared set of package versions.

Prepare the Laravel package and its releases

Before Satis can distribute your package, you need valid Composer metadata and tagged releases. Set a stable package name in composer.json, such as acme/laravel-toolkit, and tag releases in your source repository so Composer can identify available versions. For guidance on release planning, see managing package versions in Laravel.

Satis handles package discovery and delivery, while your package still handles its own Laravel integration. If you want Laravel to load your service provider automatically, add the required package-discovery metadata to composer.json. The Laravel 13 package-development documentation covers this setup; check the documentation for the specific Laravel versions your package supports.

Configure Satis to include the product

A Satis configuration file tells Satis where your source code lives, which versions to publish, and how to build downloadable archives. This example includes one commercial package and tells Satis to create ZIP archives:

{
  "name": "acme/packages",
  "homepage": "https://packages.example.com",
  "repositories": [
    {
      "type": "vcs",
      "url": "git@github.com:acme/laravel-toolkit.git"
    }
  ],
  "require": {
    "acme/laravel-toolkit": "^1.0"
  },
  "archive": {
    "directory": "dist",
    "format": "zip",
    "skip-dev": true
  }
}

The repositories entry points Satis to your package's Git repository, and require limits the output to the named package and matching versions. If you omit require, Satis enables require-all and publishes every package it finds, so list the exact products you plan to sell. You can find the full list of fields and archive options in the Satis configuration reference.

Satis generates repository metadata that Composer reads to find versions, while package archives are the files Composer downloads during installation. You can let Satis point to download archives from services such as GitHub, GitLab, or Bitbucket, or you can have Satis build its own local archives. If you rely on upstream hosts, customer installations depend on those services staying available and accessible. If you generate local archives, you host the package files yourself.

Run Satis to generate the repository:

php bin/satis build satis.json public/packages

When you run that command, Satis reads satis.json and writes the repository files to the output directory. Publish that directory on your web server, then run Satis and publish the output again whenever you tag a new release. You can schedule these runs or trigger them with a webhook, because Satis does not pick up new tags until you run a build. To avoid publishing a broken repository, have Satis write to a staging directory and move those files live only after it finishes without errors. The Satis usage documentation covers builds, updates, and archive hosting in more detail.

Connect a customer’s Laravel project

To install the package, a customer adds your Satis repository to their Laravel project's composer.json and requires the package:

{
  "repositories": [
    {
      "type": "composer",
      "url": "https://packages.example.com"
    }
  ],
  "require": {
    "acme/laravel-toolkit": "^1.0"
  }
}

They can then run Composer to install the dependency. Pick a distinctive vendor and package name, and test installation in a separate project configured the same way a customer would set it up. By default, Composer 2 treats repositories as canonical: once Composer finds a package name in a higher-priority repository, it stops looking for that package in lower-priority repositories. That prevents another repository from supplying a higher version under the same name. Avoid setting canonical: false casually, since it disables that protection. The Composer repository-priority documentation explains canonical repositories and package filters.

Protect metadata and package downloads

You cannot rely on a hard-to-guess URL to protect a private repository. Serve the repository over HTTPS and configure your web server to require authentication. The Satis documentation describes access methods including HTTP Basic authentication, SSH, client certificates, and token headers. If your server uses HTTP Basic authentication, a standard username-and-password check, customers can save their credentials in Composer's global configuration:

composer config --global http-basic.packages.example.com CUSTOMER USER_OR_TOKEN

Customers should keep real credentials in their local configuration only. Composer warns against committing authentication data in auth.json or placing credentials in a shared composer.json. For automated builds or deployments, pass secrets through a secret store or environment variables instead of committed files. See Composer's guide on authentication for private packages.

Protect your archive host as well as your metadata endpoint. Satis lets you serve archives from a separate URL, such as a CDN or object-storage bucket. If that host serves files publicly, anyone who gets hold of an archive URL can download the package without authenticating to your Satis server.

Keep access tied to the sale

Your checkout and account system must decide whether a purchase grants access, and your hosting setup must enforce that decision. Satis does not provide customer accounts, payment processing, subscription handling, or built-in per-customer permissions. Instead, your web server controls access for the entire repository at once.

You can use a shared repository with one set of credentials when every customer receives the same package versions. If individual customers need different packages, versions, or expiration rules, you have to maintain separate Satis configurations and outputs, then point each customer to their own protected URL. That adds ongoing provisioning and revocation work. If you share a single password across customers, you also cannot revoke one customer's access without breaking it for everyone else.

If you need per-customer controls and do not want to build them yourself, Satis is a poor fit. The Satis comparison with Private Packagist notes that Private Packagist offers per-user tokens, package permissions, and customer repositories as part of its paid service. Those features are separate from Satis. Also keep in mind that once a customer downloads the source code, your server cannot retract it. Protecting the repository controls who can download the package and receive future updates.

Maintain builds and archives

Make sure your build server can always read the source repository. In the example above, it needs access to git@github.com:acme/laravel-toolkit.git. Run Satis again after each release, and verify that your published directory contains both the updated metadata and any archives Composer needs.

When Satis generates local archives, test an upgrade using a lock file like a customer's. Composer's lock file records the exact package versions and checksums installed. When Satis rebuilds an archive, its checksum can change, which causes Composer to reject an existing lock file during verification. Satis documents ways to avoid this, such as keeping the archive directory between builds or disabling published checksums. Do not delete old archives without checking whether customer lock files still reference them, because Satis warns that purging old files can break installations for customers who still depend on them.

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *