PHP theorytheory 0/50 · 0%
Fundamentals · hard

48. Building a Composer Package

Publishing reusable PHP libraries.

A publishable Composer package needs a composer.json declaring its name (vendor/package), a PSR-4 autoload mapping, required dependencies with version constraints, and metadata like license and description. Semantic versioning (major.minor.patch) communicates the nature of changes to consumers who pin version ranges like "^2.0".

Publishing to Packagist.org makes a package installable via `composer require vendor/package` by anyone; tagging Git releases that match version numbers is what Packagist uses to detect new versions.

Check your understanding

  1. 1. What naming convention does a Composer package name follow?

  2. 2. What registry is used to publish public Composer packages?