composer/composer — pull request #628 by dpb587 (2012-04-27 01:11:05+00:00)
Title: Add internal support for multiple default composer repositories.

Bug fix: no
Feature addition: unofficially?
Backwards compatibility break: no
[![Build Status](https://secure.travis-ci.org/dpb587/composer.png?branch=multiple-repos)](http://travis-ci.org/dpb587/composer)

I implemented composer in a corporate environment where we setup a local composer server with some of our internal packages and mirrors, but we did not want the maintenance of a full packagist/satis mirror nor the hassle of explicitly adding our repository to every `composer.json` file we use.

This simplifies the patches we use before we recompile for deployment to our systems and developers. So our only patch would then be adding the following to the top of `bin/composer`:

use Composer\Factory;

Factory::$defaultComposerRepositories = array_merge(
array('example' => 'http://intranet.example.com/composer'),
Factory::$defaultComposerRepositories
);

As far as implementation goes the `static` usage for configuration seems unfortunate, but if you have better suggestions I can update the PR with changes. I wasn't sure the best way to test the commands, so I manually tested by creating an empty directory without `composer.json`, switching to it, and running through the four touched commands to make sure they picked up the custom repository from `Factory`. I realize this patch probably isn't a common use case right now (or perhaps there's a fully different recommended practice?), but I figured I'd submit it just in case you think others might find it useful.

We (and I, personally) have found composer very useful, even as young as it is -- so thanks!