Managing forked ZF2 modules with composer

01/20/2013

You’re using composer for your dependency management in your shinny new ZF2 project. Then you notice an issue in a thrid-party module you’re using. You fork it and submit a pull request.

I’ve done this for a few modules recently, and while waiting for the PR to be accepted I simply cloned my fork into my vendors directory. This becomes a pain (especially in teams) as your now using composer to manage some dependancies but you have to manually clone and pull your forks.

A couple of months ago I forked the popular ZfcUserDoctrineORM in order to submit a PR to allow the email field to be null, bringing the module in line with changes to ZfcUser. Unfortunately the PR, along with others, has yet to be merged.

Recently I discovered that composer can pull packages directly from github, bypassing packagist. All you need to do is add your forked repo as a VCS Repository in your project’s composer.json file like so :

Now your forked repos and your other dependancies are all managed by composer.

Share