Composer-press



Curious about Composer but already have a WordPress site? Not to worry, I have you covered. Presenting Composerpress:

Composerpress

Composerpress is a plugin that analyses your WordPress install, and generates a composer.json file you can then use retro-actively. This file acts as an inventory of dependencies, plugins, etc that are needed to set up a site, and you can use it to set up new sites quickly with the composer tool using:

composer install

It makes updating easier too, simply use:

composer update

Composer will then go and check all the dependencies and grab the latest valid versions. It’s great for automation! Simply take the output of composerpress and save it in your root directory in a composer.json file.

Composerpress handles:

  • WordPress.org packages via WPackagist
  • Plugins in Git repositories
  • Plugins in SVN repositories
  • Plugins in Mercurial repositories
  • Plugins using packagist
  • John P Blochs WordPress Core package

Composerpress currently doesn’t handle themes.

View the source on Github

Installation

Install the plugin by doing a git checkout/clone into your plugins folder, and activating, e.g.:

mkdir composerpress
git clone https://github.com/Tarendai/composerpress.git .
composer install

You could also download the repository as a zip file via Github, and do the final composer install step to grab the dependencies.

If you need to update Composerpress do the following:

# update composerpress
git fetch origin
# update dependencies
composer update

Note: Composerpress requires PHP 5.3 or later, git will need to be available on the command line for git repository support, and PDO is needed for subversion repository support. If PDO is unavailable or PHP 5.3 is unavailable, the composer install step will tell you. Mercurial/hg does not need to be installed for Mercurial repository support.

The resulting composer.json will install WordPress to a WordPress subfolder, this can be changed by adding:

"extra": {
    "wordpress-install-dir": "custom/path"
}

Click here for more information on the WordPress core composer installer. You can set the path to “.” for a non sub directory install, but this will prevent composer from updating the WP Core and may cause issues.

For more details on using Composer with WordPress, Rarst has a helpful microsite with examples here.

You may also find this WordPress install starter project by John P Bloch using composer useful.