General Guides

  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?

Besides installing Magento 2 extensions via SSH manually, installing via composer is another very common and simple way used by a lot of Magento users.

In this article, we will provide you with a step-by-step instruction about how to do to get a Magento 2 extension installed on the website by Composer.

Now, let’s start with us!

Step 1: Create Access Keys And Get The Package Information

Send us an email to [email protected] along with the order number. We will create access keys as your requirement and then provide you with information about the packages.

Step 2: Configure Composer Repository

Firstly, you need to add a new composer repository to the BSSCommerce Composer Repository.

Type the following command in the root directory of Magento:

composer config repositories.bsscommerce composer <path>

In the path indicate:

Step 3: Install Extension

Once you have the package name and version, install the Magento 2 extension by executing the following command:

composer require package_name – For the latest version

composer require package_name:version – For the older versions

For example, you want to install the BSS One Step Checkout extension, please execute the following command:

  • For the latest version: 

composer require bsscommerce/module-one-step-checkout

  • For version 2.1.2:

composer require bsscommerce/module-one-step-checkout:2.1.2

When you run this command for the first time, CLI will ask you to enter the Username and Password. Please fill in the access key created in Step 1. 

Note: The Public key corresponds to the Username, and the Private key corresponds to the Password.

Composer will inform a message to you. If you want to save the Access key, please type Y.

In case you already saved the Access key in the server, but you want to use another Access key, do the following:

Open the file ~/.composer/auth.json and delete the username/password of the corresponding repository:

Then you install the module as usual:

php bin/magento setup:upgrade

Note: In case of occurring error, it could be that the Access key you entered is wrong, your account does not have access to this package, or the version you entered does not exist.

  • If you want to update the latest version of the extension, run this command:

composer update package_name

  • If you want to remove the extension, run this command:

composer remove package_name

  • If you want to update another version, not the latest version of the extension, run this command:

composer remove package_name

composer require package_name: version

Note: If you installed extensions via SSH (by uploading the package) before, then when updating the extension via composer, running the command setup:upgrade will fail. In this case, you have to delete the folder you uploaded in app/code/…

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?