Magento 2 – Make Module Installable from GitHub/Bitbucket

composerextensionsmagento2

I want to make my extension, say Easy Template Path Hints which is available on github(may be on bitbucket someday) installable via composer. Tried many variation but it's not working.

Here are some of my attempts

1. Using following series of composer commands

composer config repositories.magepsycho git https://github.com/MagePsycho/magento2-easy-template-path-hints.git
composer require magepsycho/magento2-easy-template-path-hints:1.0.0

This resulted in error

The requested package magepsycho/magento2-easy-template-path-hints
could not be found in any version, there may be a typo in the package
name.

2. Manually editing the composer.json

Added the following under "require" node

"magepsycho/magento2-easy-template-path-hints": "master"

And the following under "repositories" node

"magepsycho": {
    "type":"package",
    "package": {
        "name": "magepsycho/magento2-easy-template-path-hints",
        "version":"master",
        "source": {
            "url": "https://github.com/MagePsycho/magento2-easy-template-path-hints.git",
            "type": "git",
            "reference":"master"
        }
    }
}

And then

composer update

There was no any error and it successfully downloaded the extension under vendor folder. But was not installed in app/code folder

May be listing the module to packagist.org may help but I want it to be installable via git also.

Any Suggestions?

Best Answer

I was able to fix the issue by using following commands:

composer config repositories.magesycho-magento2-easy-template-path-hints git git@github.com:MagePsycho/magento2-easy-template-path-hints.git
composer require magepsycho/magento2-easy-template-path-hints:dev-master

Explanation

Before I was using magepsycho/magento2-easy-template-path-hints:1.0.0 instead of magepsycho/magento2-easy-template-path-hints:dev-master.

If you are loading a package from VCS repository (git, svn etc.), version should be a branch name prefixed with dev-

Source: https://getcomposer.org/doc/05-repositories.md#vcs

Related Topic