Using forks with composer – late night edition

Using your forks of certain packages with composer is actually pretty easy:
Add the repo of the fork to the repositories block of your composer.json, you might need to change the version to f.e dev-master and thats it. Great. Actually.

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ivoba/SomeBundle.log"
        }
    ]

But there are some traps, especially when you are mentally already weekend bound:

When working in a team, take care that you dont add your fork as a private repo.
This happens when you use the @ notation like ‘git@github.com‘. Its tempting because it will be the clone url on github when you are logged in, which is very likely.
If you do so your team mates will get errors like this:

Failed to execute git clone --no-checkout 'git@github.com:ivoba/SomeBundle.git' [...] && git remote add composer 'git@github.com:ivoba/SomeBundle.git' && git fetch composer

So better change it to the notation of public repositories like ‘git://github.com‘ but take care that you change the whole path and not only the protocol like:

git://github.com:ivoba/SomeBundle.git

This will look in port “ivoba” ;) and you will get an error like:

fatal: Unable to look up github.com (port ivoba) (Servname not supported for ai_socktype)

If you try the same with https you will still fail with:

Cloning into bare repository [...]                                                         
  fatal: Unable to find remote helper for 'https'

So the correct path for public repos is:

git://github.com/ivoba/SomeBundle.git[/code]
or

https://github.com/ivoba/SomeBundle.git

with colon slash slash domain slash !

Stupid mistakes but they happen, though its all written in the docs:
https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository
and
https://getcomposer.org/doc/05-repositories.md#using-private-repositories
but sometimes reading alone isnt sufficient ;).

One Reply to “Using forks with composer – late night edition”

Comments are closed.