BuddyPress lead developer Paul Gibbs committed support for Composer to BuddyPress core this week. Developers who want to check it out can find the json file at: trunk/src/composer.json.
If you’re not yet familiar with Composer, it’s essentially a tool for dependency management in PHP. It is designed to manage packages on a per-project basis by bringing in any dependent libraries that you declare in the composer.json
file. The dependencies are then automatically installed in a vendor
directory or other specified location inside your project.
BuddyPress is not yet listed on Packagist.org but should be added soon. Once it’s listed there, it can easily be declared as a dependency after the next version (2.2) is released.
[code]{
"require": {
"buddypress/buddypress": "~2.2"
}
}[/code]
BuddyPress 2.2 is expected in mid-January 2015, according to Gibbs’ reply in the ticket to add Composer. He plans to configure Packagist to pull from http://plugins.svn.wordpress.org/buddypress/.
Because BuddyPress is identified as a WordPress plugin in its json file (“type”: “wordpress-plugin”), composer/installers will by default send it to the wp-content/plugins directory.
If you can’t wait two months, and you’re dying to use BuddyPress with Composer right now, there’s an alternative method. I spoke with WordPress Composer evangelist Andrey Savchenko (@rarst) regarding the news. He suggests that in the meantime developers could use wpackagist, which provides a mirror of the WordPress plugin and theme directories as a Composer repository.
[code]{
"require" : {
"wpackagist-plugin/buddypress": "~2.1"
},
"repositories": [
{
"type": "composer",
"url" : "http://wpackagist.org"
}
]
}[/code]
If you search for “WordPress” on Packagist, you’ll find many other projects, which can also be easily added into your next BuddyPress project. Composer support makes it easy to create a master composer.json
file for your projects, that will save you time by allowing you to load all of your dependencies in a matter of seconds.
You’ve always been able to get anything on the WordPress repo with WPackagist. Literally, any plugin or theme in the svn repos.