Publishing a PHP library to Packagist.org 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.
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.*" } }
Login to your Packagist.org account.
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 Packagist.org, you can now include it in your projects using composer.
composer require vendor-name/package-name
Add new comment