Curious about Composer but already have a WordPress site? Not to worry, I have you covered. Presenting 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.
Sweet thing: @Tarendai published ComposerPress for #WordPress http://t.co/Qe0emMED2Y
— Franz Josef Kaiser 🇦🇹 (@unserkaiser) October 1, 2013
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.
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
@Rarst I'm lazy and haven't taken the time to learn it. But I recognize its value. And tools like this (http://t.co/VdmovggORC) rock!
— Eric Mann (@EricMann) October 3, 2013
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.