Magento2 – Composer & development practices

Until the release of Magento 2.1 there has only been two real ways of setting up your Magento development environments, neither of which i saw as being a good solution.

Method 1

(tl;dr) You can’t adequately use version control on your individual extensions

The first just dumping your extenions into the app/code/ folder, after all your root composer.json points to it via the psr0. However this method doesn’t really allow you to use git branching to its full potential.

    "autoload": {
        "psr-0": {
            "": "app/code/"

Method 2

(tl:dr) You can version each individual extension, however uncommited changes were easy to overwrite and switching individual branches wasn’t straight forward.

The other option was add your extensions to composer.json as separate repositories.

composer config repositories.clearandfizzy-helloworld git [email protected]:clearandfizzy/module-example.git
composer require clearandfizzy/module-example:1.0

Which would produce something like the following..

    "repositories": {
        "clearandfizzy-module-helloworld": {
            "type": "git",
            "url": "[email protected]:clearandfizzy/module-example.git"

    "require": {
        "clearandfizzy/module-helloworld": "dev-master"

Everytime you switched branch to work on a new feature you would need to git checkout on your vendor/clearandfizzy/module-helloworld directory then change your composer.json. A composer update would overwrite any un-commited changed.

Method 3 – Magento 2.1 and Composer 11

(tl;dr) Separate local repositories, you can switch branches with fewer steps.

Composer 11 allows you to use the repository type of “path” instead of “git”, this merely creates a symlink in vendor to your locally cloned git folder. This allows your to develop your code outside of the Magento codebase yet still have those changes appear instantly.

composer config repositories.clearandfizzy-example path ../local-repos/module-example
composer require clearandfizzy/module-example:*

Which produced something similar to this.

    "repositories": {
        "clearandfizzy-module-example": {
            "type": "path",
            "url": "../local-repos/module-example"

   "require": {
        "clearandfizzy/module-example": "*"


Buy Me A Coffee
back arrowBack to Index