slugger



How to create a Composer package from scratch

Available to Premium members only
  • avatar
  • 93 Views
  • 16 mins read
Preview image

A helper class, a small client wrapper or a set of validation rules often starts in one project and ends up copied into the next one. From that point the copies drift apart, a bug fixed in one of them stays open in the rest, and there is no version number to refer to when something changes.

Turning that code into a Composer package removes the copies. The requirements are modest, since a package is a directory containing a valid composer.json file, a Git repository hosting it, and a listing on Packagist that tells Composer where to find it.