This article will instruct you on installing Amasty Magento 2 extensions (or any other Magento 2 extensions) using the Composer. A lot of our customers were asking us how to do this with our extensions, so here you are!
Note: Please make sure that you know what you’re doing when following the instructions. If any actions or terms in the article cause confusion, please ask a professional to do the job.
As well as you install Magento 2 using Composer, you can install our extensions, for this, you’ll need:
- An installed Magento 2 and a Composer on your server
- SSH server credentials
- https://magento.com/ Magento Marketplace account
- Extension package
Today we’ll consider the settings on the example of our M2 Shop by Brand extension:
- custom sorting filters for brand products
- slider with all brands
- all-brands page
- filter by brand
- unique CMS for every brand
- brand logo on product pages
Step 1. Magento.com account
Please go to https://magento.com/ and create an account, if you haven’t done this before.
Log in the account and go to the Marketplace tab:
Proceed to My Access Keys menu item:
You can create a new access key or use the existing one:
Save the access keys, as they will be used in the following steps.
Make the local repository ready
Log in to your server via SSH\SFTP and create a repo folder where it’s convenient for you. In our case, the full folder path will be /www/private/magento/repo
Note: You can choose any name for your folder, but please make sure you change it while performing the following actions.
Copy your extensions folders into this newly created folder. Here’s how the repo folder will look after you do this:
If the extension package was downloaded from Amasty website, you need to place the contents of /upload/app/code/Amasty/ into your newly created folder.
If your extension package has only the contents of these folders, you’ll have to create the folders manually. To get the correct folder name, check the registration.php file:
Adding extensions to Composer and installing them
Log in to your server with SSH and go to Magento 2 folder.
Being in this folder, send the following commands to Composer, telling it to add the extensions to the repository. Don’t forget to replace the module name, the folder path and the module folder name with your own ones:
[php]composer config repositories.module_name path /www/private/magento/repo[/php]
module_name is the name of the extension, and you can name this as you want.
Now that we have added the extensions to the Composer, we can install them. This command will install amasty/[module_name]:
[php]composer require amasty/[module_name][/php]
If you’re running the command for the first time, the Composer will ask for your magento.com account credentials. Here’s where you’re going to use Public Key and Private Key, obtained before.
Here’s how the command output will look like:
Now, let’s finish the installation process:
[php]php bin/magento setup:upgrade[/php]
Congrats, your Magento extension is now installed via Composer.
- To install Amasty Base, use the same steps, but mind the Base extension folder:
[php]composer config repositories.amasty_base path /www/private/magento/repo/Base/[/php]
And for installation use the following command:
[php]composer require amasty/base[/php]
- You can install several Amasty extensions at once, adding the names of all the required extensions like so:
[php]composer require amasty/shopby amasty/promo amasty/rules[/php]
- If you’re installing an extension which is dependent on several extensions, you don’t need to list all the dependencies here. For example, amasty/shopby has six dependencies, but it’s enough to list just amasty/shopby for the installation.
That is all for today.
Do you have any questions on Magento 2 Composer install or Magento Composer install? Please feel free to ask us in the comments section.