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 step-by-step instructions on how 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 firstname.lastname@example.org along with the order number. We will create access keys as per 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:
- https://composer.bsscommerce.com/community – for Community extensions.
- https://composer.bsscommerce.com/enterprise – for Enterprise extensions.
Step 3: Install Extension
A - Install a whole package/kit/combo or individual 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/…
B - Install specific extensions within a package/kit/combo
This section is only useful if you want to install the specific extensions within a package/kit/combo, e.g. you want to test some specific functions first, or there are some extensions you do not want to install at all.
- To install particular modules within a package, you just have to install them separately:
composer require bsscommerce/add-multiple-products
The version to be installed will be the latest version.
- To remove specific modules, similarly, you remove them separately:
composer remove bsscommerce/add-multiple-products
For the case of installing a package/kit/combo, you can only choose one among these 2 options: install the whole package or install individual extensions. Using both ways may result in some issues.
If you already followed one approach, and want to switch to the other, you need to run the remove command first.
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 is helpful for you!