Magento 2 : how to install magento 2 Extesion using composer from github private repository?

All we need is an easy explanation of the problem, so here it is.

I have developed one extension and I have uploaded that in my GitHub private repository

https://github.com/bhaveshpp/Percentoffsale

now I have tried to install it using

composer require –dev bhaveshpp/Percentoffsale

but I got error

In InitCommand.php line 727:
Could not find a matching version of package bhaveshpp/Percentoffsale.
Check the package spelling, your version constraint and that the
package is available in a stability w hich matches your
minimum-stability (stable).

require [–dev] [–prefer-source] [–prefer-dist] [–no-progress] [–no-suggest] [–no-update] [–no-scripts] [–update-no-dev] [–update-with-dependencies] [–update-with-all-de pendencies] [–ignore-platform-reqs] [–prefer-stable] [–prefer-lowest] [–sort-packages] [-o|–optimize-autoloader] [-a|–classmap-authoritative] [–apcu-autoloader] [–] []…

this is my composer.json file code

{
    "name": "bhaveshpp/Percentoffsale",
    "description": "A Magento 2 module that creates discount",
    "type": "magento2-module",
    "version": "0.1.0",
    "license": [
      "OSL-3.0",
      "AFL-3.0"
    ],
    "require": {
      "php": ">=7.0.0",
      "magento/framework": "~100.0.4"
    },
    "autoload": {
      "files": [ "registration.php" ],
      "psr-4": {
        "Zarathemes\\Percentoffsale\\": ""
      }
    }
  }

I have also try this solution

How to install an extension on a private Github using Composer?

{
    "name": "bhaveshpp/Percentoffsale",
    "description": "A Magento 2 module that creates discount",
    "type": "magento2-module",
    "version": "0.1.0",
    "license": [
      "OSL-3.0",
      "AFL-3.0"
    ],
    "require": {
      "php": ">=7.0.0",
      "magento/framework": "~100.0.4",
      "bhaveshpp/Percentoffsale": "dev-master"
    },
    "autoload": {
      "files": [ "registration.php" ],
      "psr-4": {
        "Zarathemes\\Percentoffsale\\": ""
      }
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "[email protected]:bhaveshpp/Percentoffsale.git"
        }
    ]
  }

But i have got the same error.

If any one have a solution then provide

Any help would be appreciated.

Thanks in advance..!

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Please set your repository Private to Public because the Private repository is not working for this operation.

Please set your package name in a lower case
“bhaveshpp/Percentoffsale” to “bhaveshpp/percentoffsale”.

Also, Check your GitHub repository into the https://packagist.org/

This solution will solve your issues.

Try with following composer.json file

{
    "name": "bhaveshpp/percentoffsale",
    "description": "A Magento 2 module that creates discount",
    "type": "magento2-module",
    "version": "0.1.0",
    "minimum-stability": "dev",
    "prefer-stable": "true",
    "license": "OSL-3.0",  
    "require": {
        "php": ">=5.4.0",
        "bhaveshpp/percentoffsale":"[email protected]"
    },
    "autoload": {
      "files": 
        [ 
            "registration.php" 
        ],
      "psr-4": {
            "Zarathemes\\Percentoffsale\\": ""
        }
    }
  }

In Github Repository, Release and Add a Tag.

Method 2

Try to use this

"repositories": {
    "bhaveshpp-percentoffsale": {
        "type": "git",
        "url": "your_ssh_path_to_repo"
    }
}

Then execute “composer require bhaveshpp/percentoffsale”

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply