In addition to installing Magento extensions manually via SSH, you can also expand its capabilities by using the Adobe Commerce Marketplace as a repository to add them. For example, you can purchase a theme to change the appearance, a language pack, or a module to add different online payment options using Composer to install them.
In this article, we explain the first steps you need to take to install a module from the official repository using Composer, and we also describe various actions you can take to manage these extensions.
Obtaining and configuring keys
First, you will need to log in or register with Adobe Magento, so you can obtain the keys needed for Composer by clicking Access Keys in your Marketplace profile.
From there, you can generate or obtain the keys for the corresponding version of Magento.
You can find more information in the official documentation on obtaining the keys by clicking here.
Once you have obtained the keys, access the server via SSH and copy the sample authentication file for Composer:
# cp /var/www/html/magento2/auth.json.sample /var/www/html/magento2/auth.jsonThen, edit the copied credentials file:
# nano /var/www/html/magento2/auth.jsonAnd enter the public and private keys inside the quotation marks in each corresponding section:
"username": "<public-key>",
"password": "<private-key>"Also add or check for the Magento repository in the Composer file:
# nano /var/www/html/magento2/composer.jsonThe file must contain the following lines; if it does not, you can add them after the first bracket:
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],You can find more information in the official Composer documentation by clicking here.
Updating Composer
Before installing the extension, you may be prompted to update Composer, so run:
# composer updateHowever, if you installed Composer through the apt repository or a similar repository, the update will not be available and will return an error. Therefore, obtain the Composer installer:
# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"Before installing it, check the path of the current installation:
# which composerIt will display the path, for example /usr/bin/composer (the default in the preinstalled image). To install it in the same directory, run the following command, specifying the binary directory path:
# php composer-setup.php --install-dir=/usr/bin --filename=composerAfterward, you can update Composer as usual:
# composer update Installing a module
Once you have completed all the previous steps, you can purchase the desired module from the Market. Once the process is complete, under My Purchases the available extension or extensions should appear:
You can then check the name under "Component name" and install the module using Composer:
# composer require stripe/stripe-paymentsNext, you will need to register the extension in Magento by updating it:
# php bin/magento setup:upgradeHowever, if this is a production environment, you will then need to run:
# php bin/magento setup:di:compile && php bin/magento setup:static-content:deploy -fFinally, we recommend clearing the Magento cache:
# php bin/magento cache:flush && php bin/magento cache:cleanWith this final action, the module will be installed and active in Magento.
Important information
When you use Composer or make changes through it as another user, the ownership of files and directories will change, so you will need to check or modify ownership in the Magento 2 directory for the corresponding web user.
Below, we explain several actions that may be useful for managing modules.
Checking module status
Check the status of installed modules by querying the Magento database:
# mysql -u root -e "SELECT * from magento.setup_module"Query module status using the Magento binary:
# bin/magento module:statusQuery the status of a single module using the binary:
# bin/magento module:status nombre-moduloEnable or disable a module
Enabling a module:
# bin/magento module:enable nombre-modulo --clear-static-contentDisabling a module:
# bin/magento module:disable nombre-modulo --clear-static-contentUpdating or installing a specific version of a module
Updating a module:
# composer update vendedor/nombre-moduloInstalling a module with a specified version:
# composer require 'vendedor/nombre-modulo ^x.x.x'Updating Magento to register a module installation or update:
# bin/magento setup:upgrade --keep-generatedClear the Magento cache:
# bin/magento setup:static-content:deploy -f# bin/magento cache:cleanUninstalling a module:
Removing the module:
# composer remove stripe/stripe-paymentsRegister the module uninstallation in Magento:
# php bin/magento setup:upgradeReconfigure Magento:
# php bin/magento setup:di:compileClear the Magento cache:
# php bin/magento setup:static-content:deploy -f# php bin/magento cache:cleanWe hope this article has been helpful. If you have questions about this or any other issue related to your servers on Clouding, feel free to contact soporte@clouding.io. We're here to help!