How to install magento 2 marketplace module by composer approach?

This article will helpful for the Installation of the Magento Marketplace extension with Composer in Magento 2.

To install an extension or download the extension code for review from the Magento marketplace, you must need to use Composer.

To promote the best practice of installing extensions via Composer, direct package download from the My Purchases page has been disabled. (Source: Adobe Marketplace site)

Let’s take an example of installing a module from the Marketplace.

I hope you are login with your marketplace account Magento Login.

1) Let’s download an extension called Hubspot Integration Extension Link after placing an order from the marketplace. You can download any extension you want but this is for demo purposes.

2) Once downloaded, it will be shown in your account Magento Dashboard,  You can see the link, My Purchase from your marketplace account dashboard.My Purchase

Now while you click on My Purchase Link, you will be able to see your extension on that page.

3) Now Click on Access Keys from the Magento Marketplace Dashboard, you can see the Access Keys link on the above page.

4) Add Public and Private Key to the auth.json file in the project root directory. Check auth.json file is available or not in the root path of the project, if not create the auth.json file and add the username as the public key and password as the private key.

{
  "http-basic": {
    "repo.magento.com": {
      "username": "PUBLIC_KEY_OF_MAGENTO_ACCESS_KEY",
      "password": "PRIVATE_KEY_OF_MAGENTO_ACCESS_KEY"
    }
  }
}

5) Add the given line in the composer.json file which resides at the root of your project,

"repositories": [
   {"type": "composer", "url": "https://repo.magento.com/"}
]

6) Now you can run the command from your CLI to install the module via composer, Extension name can be fetched from the download page of your account.

Run Command from the Magento Root path with CLI,

composer require eyemagine/hubspot

Module Version

Here in the image, the Module name is required to install the extension using composer.

By default, the composer fetches the latest version of the extension to download and install in the system.

composer require <MODULE_NAME>

This is the basic flow of the install module via composer in Magento.