How to Publish a PHP Library to to be used in Composer

Amazon packages

Publishing a PHP library to is a straightforward process that involves a few simple steps. An existing Github repository that is public is required (although private is also available) in order to submit to Packagist.

  1. First, in your GitHub repository for your PHP library, and make sure it has a composer.json file with the required information about your package. A minimal composer.json file like this will do:

        "name": "vendor-name/package-name",
        "description": "A short description of what your package does.",
        "require": {
            "php": ">=7.4",
            "another-vendor/package": "1.*"
  2. Login to your account.

  3. Click on the "Submit" button on the Packagist top menu, and add the URL of your public GitHub repository. Packagist will automatically detect your package's details from the composer.json file.

Connect to Github

Packagist provides an option to set up automated updates for your package, so it stays up-to-date with the latest versions, by connecting it to your GitHub account.

Adding your library/package

With your PHP library now published in, you can now include it in your projects using composer.

composer require vendor-name/package-name

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.