SyntaxStudy
Sign Up
PHP Creating a Composer Package
PHP Intermediate 4 min read

Creating a Composer Package

Publishing a Package

Any PHP project with a valid composer.json and a Git repository can be published to Packagist.

Example
// Minimal composer.json for a package
{
  "name": "your-vendor/your-package",
  "description": "A helpful PHP library",
  "type": "library",
  "license": "MIT",
  "require": { "php": "^8.1" },
  "autoload": { "psr-4": { "YourVendor\\YourPackage\\": "src/" } }
}
// Steps: push to GitHub → link on packagist.org → submit
Pro Tip

Use semantic versioning tags (v1.0.0, v1.1.0) — Packagist picks them up automatically.