Using Git Repository for Composer

Magento 2 uses composer for downloading and installing external dependencies. However one can easily install extensions using composer. This article highlights the steps required to deploy your module directly from git.

Adding composer instructions to module

In the root folder of the extension add a composer.json file with the following basic information.

    "name": "<vendor in small case>/<extension code in small case>",
    "description": "<extension description>",
    "require": {
        "php": "~5.5.0|~5.6.0",
        "magento/framework": "<Magento minimum version>",
        "magento/magento-composer-installer": "*"
    "type": "magento2-module",
    "version": "<extension version>",
    "license": [
    "extra": {
        "map": [
                "app/code<vendor in Camel Case>/<extension code in Camel Case>"/*",
                "<vendor in Camel Case>/<extension code in Camel Case>"

Upload the code to Git.

Registering the git repository in composer

In the Magento command line run the command

composer config repositories.vcs git <url to the git repository>

Installing / Updating the module

To install or update the module run the command

composer require <vendor in small case>/<extension code in small case>:dev-<branch>

Note: Composer by default will search for the extension version under the git Tags. This can be annoying during development phases where the code might be changing with fixes. To instruct Composer to download the code from a branch, the branch name needs to be prefixed with ‘dev-‘


Loading a package from a VCS repository
Have Composer use development branches