1. Home
  2. Docs
  3. General Guides
  4. How to install a Magento extension?
  5. How to install Magento 2 Extension via Composer?

How to install Magento 2 Extension via Composer?

Beside the normal method, installing Magento 2 extensions via composer is another very common and simple way used by a lot of Magento users.

In this article, we will provide you with step-by-step instruction about how to do to get a Magento 2 module installed on the website by composer. To understand more easily, we take an example of installing Magento 2 Customer Approval extension

*NOTE: Before installing an extension by composer, you need to have right to access to the git repository. You can select one of the two following methods: 

  • Send us an email to sales@bsscommerce.com along with order number and Bitbucket account. We will share GIT repository for you. (Permission: View Only)
  • You create a GIT repository for the module by your GIT account.

Now, let’s go start with us!

Step 1: Login to Bitbucket

You login to the Bitbucket and then, navigate to package_m2_magento2-customer-approval repository.

 

Login to Bitbucket

Step 2: Get the repository URL

  • Click on the Clone button and a popup will appear for you get wanted information.
This image has an empty alt attribute; its file name is 2-Clone-button-1024x683.png
  • Next, you select HTTPS from the drop-down list.
  • The repository URL is the one displayed behind the “git clone” as you can see in the following image.
Chose HTTPS and repository url

Step 3: Add the repository to Magento

  • You open the composer.json file in your Magento root folder.
  • Add your Bitbucket repository (in step 2) to the repositories node:
{

"type": "git",

 "url": "YOUR_BITBUCKET_REPOSITORY"

}

You can get the composer.json as below:

Composer.json

Step 4: Get the package name of the extension

  • You go to the package_m2_magento2-customer-approval repository in Bitbucket.
  • Open the composer.json file
Open the composer.json file
  • You can see the package name included in the name node. In this example, the package name is bsscommerce/customer-approval:
  •  
package name

Step 5: Install the extension

  • You login to your SSH and go to Magento folder
  • Finally, you run this command: composer require <package_name>:dev-master
  • If your system asks to enter the password for your bitbucket repository, please use your bitbucket password.

This is a complete installation process you can follow to have a Magento 2 module on your website.

Thanks for reading our article! Hope it helpful for you!

Was this article helpful to you? Yes No

How can we help?