This site was asked for too many times to not happen. Think of it as unofficial companion to Composer documentation for WordPress developers.

Prerequisites

Install Composer by following instructions in documentation for *nix or Windows.

Why Bother

Composer is dependency manager command line utility and accompanying infrastructure tools. It is made in PHP and for PHP.

It can help you improve how you develop, share, make use of, host, and deploy your WordPress code and whole site stacks.

Dependency

So what is “dependency”? Basic building block of Composer world is “package” and it is:

  • a folder (or file)
  • probably with PHP code
  • preferably with composer.json file
  • preferably semantically versioned

So pretty much anything can be package. Packages preferably contain information that Composer can read and process. That information can include which other packages at which versions are required as dependencies.

In WordPress world Composer package can be:

  • WordPress core itself
  • extension (plugin or theme)
  • whole site (with core, themes, and plugins as dependencies)

It also opens up a way to depend on (and share) generic PHP libraries, without embedding their sources.

There is also special kind of platform package dependency. It allows to depend on specific PHP version and extensions.

Manager

Packages are not of much use somewhere out there. That is why from a starting point (“root” package) Composer will:

  • calculate its dependencies
  • download them (or retrieve from local cache)
  • organize them into directories
  • produce combined class autoload file

Composer thrives on compatibility and packages can come from:

Recipes

This site will provide you with information on how to:

Case Studies

Theory is no replacement for experience and there are already practical examples of using Composer with WordPress code (old and new) available.

Updating for Composer

Developing for Composer

  • Laps plugin by Andrey “Rarst” Savchenko
  • Fragment Cache plugin by Andrey “Rarst” Savchenko