Experimental community plugins mirror as composer repository: Revision

Last updated by Paweł Sroka

If you hear for the first time about composer, that's not a thread for you. Go learn about it and come back when you're familiar.

Introduction

I was experimenting for some time with making elgg plugins distribution easier. One of the approaches was to add plugins search and install directly to dev install. It's still work in progress, but already works and is available here: https://github.com/Srokap/srokap_plugin_installer

Another approach is following trend of many other frameworks that already use composer as optional way of installation or sometimes as the only way. My experience with annoying conflicts on git submodules made me think to replace them with composer dependencies as well as simplification of our community.elgg.org updates process.

This is not officially supported way of installing plugins! It might be at some point, but that's still decision to be made and scheduled for 1.10 milestone.

Repositories

You can use composer for installing elgg plugins already, since I wrote installer for Elgg plugins to composer/installers that got merged into version 1.0.8. You can already find few Elgg plugins on https://packagist.org/ that I've been using for testing.

Having littile plugins available would be a main blocker for this to be used, so I'm also setting up experimental mirror of plugins uploaded to community.elgg.org, so they can be installed with composer as well. It's currently set up at: http://composer.i.srokap.pl/ and running on my raspberry pi, so please don't benchmark it and forgive awful connection ;-)

How is repository made?

It's made from an older snapshot of community data (more than 1 month old), so new plugins will be missing. Currently there are missing .tar.gz archives, archives containing other than exactly one manifest.xml file, containing corrupted manifest.xml, versions restricted by composer version format (fancy suffixes mostly).

Author name is the same as community username of project owner. Package name is taken from 'id' field in manifest.xml or directory name inside archive if first option is not set. It's not perfect - I'll be fixing it.

I'm running it using satis which is very leightweight repository version, but handles our more than 1500 plugins and over 2000 versions nicely so far. We might want to move to packagist fork, but I see no real benefit so far.

It will be upgraded more often in future of course.

How to make elgg plugin work with composer?

First option is to just upload to community and wait for http://composer.i.srokap.pl/ update. This way has it's limitations, ie. can't checkout dev-master

Second and recommended option is to add comoser.json to your plugins project root and ping packagist.org to fetch it. You need to take care of 2 aspects:

  • Set type field to 'elgg-plugin'
  • Require "composer/installers" in version  >=1.0.8
  • Use name of the package the same as the target name of plugin directory in /mod/. Plugins with name AUTHOR/PLUGIN get installed into /mod/PLUGIN/

Working example: https://github.com/Srokap/code_review/blob/master/composer.json
The rest of the fields are the same as for every other composer package.

How to use it?

Simplistic example ot adding tidypics to your project is here: https://gist.github.com/Srokap/10608474

What's required/recommended:

  • Add composer.i.srokap.pl repository if you want to fetch plugins from there in addition to packagist.org
  • [recommended] set "minimum-stability" to "dev", otherwise you won't be able to install development versions of some plugins (composer will report that can't find particular package)

Is it stable?

No. It's still under development. Some details may change. Most importantly - package names may change in future, so feel free to use it, but don't be supprised if you'll need to update your composer.json now and then.

I'd very appreciate feedback on the feature, if you find it useful or if you have problems other than not knowing composer ;-)