Hello to Amasty blog readers!
Today we’re announcing the availability of Amasty extensions for Magento 2 in our official repository, from which you can now install our modules with the help of the Composer.
Get your FREE PDF guide to install/update mods with Composer!
Only Amasty extensions for Magento 2 are available via the repository. Right now, Magento 1 extensions from Amasty are not available there.
- Get your FREE PDF guide to install/update mods with Composer!
- Why we are opening the official Amasty repository
- Advantages of Composer
- How to install Magento 2 extensions from Amasty repository via Composer
- Magento 2 Extension Update via Composer
- Delete Extensions via Composer
- Using Composer with multiple Amasty.com accounts and one Magento installation
- What if I get ‘COULD NOT FIND PACKAGE’ error?
Why we are opening the official Amasty repository
The decision to develop this opportunity was made because a lot of Amasty clients asked for this option to have some additional installation and updates safety, as well as the convenience of maintaining the extensions. For advanced users, Amasty Composer is a new option to install or update the extensions via the command line, which is fast and hassle-free. You can install it on any OS: Windows, Linux, Ubuntu, and macOS. However, Composer requires the PHP version from 5.3.2 and above to run.
What is more, with this option we’re solving a common problem some of our clients faced when buying Amasty extensions for Magento 2 from Magento Marketplace.
Before, if the user had installed the extension from the Marketplace, and then installed the new version obtained from Amasty.com website (using the package manually, not via the Composer), he or she would lose all the settings. Now this issue is solved, because you can use the Amasty repository for updating extensions, and this way no extension settings are lost now.
Advantages of Composer
Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. If you spend some time to see into this tool, you understand how many advantages it has:
- It’s hard to ruin all in one click thanks to addictions;
- It’s convenient if you are ready to learn a little bit of new information;
- It’s easy to update your packages;
- It’s handy to manage your extensions;
- It’s simple to transfer or rebuild your instance (Сomposer install).
How to install Magento 2 extensions from Amasty repository via Composer
The following instruction assumes that you have already installed and set up the Composer tool. If you haven’t installed it yet learn how to do it here.
To work with Amasty Composer you need to create a Customer Account on Amasty.com (to get Access Keys).
Step 1. Log in to your server via a Command line:
Step 2. Set the directory where you would like to install the extension. Usually, for such purposes, the Magento root folder is selected.
Step 3. Connect to the Amasty Composer Repository:
[php]composer config repositories.amasty composer <path>[/php]
In the path indicate:
- https://composer.amasty.com/community/ – for community extensions.
- https://composer.amasty.com/enterprise/ – for enterprise extensions.
Step 4. To get authorized use generated in your Customer Account :
Amasty.com → Account → My Access Keys
Use the Public Key as a login and the Private Key – as a password.
NEW: How to save Access Keys?
You can save the keys in the repository so you won’t have to get authorized every time.
#1. Save the keys manually in the repository;
#2. Go to your Magento docroot directory to insert: composer config – -auth http-basic.composer.amasty.com $COMPOSER_AMASTY_USERNAME* $COMPOSER_AMASTY_PASSWORD**
*$COMPOSER_AMASTY_USERNAME – your Public Key
**$COMPOSER_AMASTY_PASSWORD – your Private Key
Step 5. After the authorization is successfully finished, you can start installing/updating your Magento 2 Composer.
First, take a look at the module names in your Customer Account to make sure you call the necessary module via the Composer correctly.
Please go to Amasty.com → Account → My Downloads for paid extensions and open the My free products tab for free modules.
You will find module names for the Composer in the ‘My Composer Packages’ section.
Step 6. To install the Magento 2 module, please execute the following command:
[php]composer require amasty/color-swatches-pro [/php]
Step 7. To install the module execute the command:
[php]php bin/magento setup:upgrade [/php]
Magento 2 Extension Update via Composer
1. The extension update process is the same as the module installation process. To update the extension, simply execute the command:
[php]composer update <composer_name>[/php]
Instead of the ‘composer_name’ please specify the corresponding module name which is indicated in your customer account. This command updates only the last two version numbers: e.g. 1.x.x ( only x.x will be updated).
To update the version from 1.x.x to 2.x.x you need to execute the following command:
[php]composer require <composer_name> ^x.0.0 –update-with-dependencies[/php]
Where x corresponds to the first version number. For example, to update the Improved Layered Navigation Extension for Magento 2 from repository the 1.x.x version to the 2.x.x version you need to execute the command:
[php] composer require amasty/shopby ^2.0.0 –update-with-dependencies[/php]
2. To update all modules execute the command:
[php] composer update [/php]
Delete Extensions via Composer
To delete the extension via Composer, please execute the command:
[php] composer delete <composer_name> [/php]
Instead of the ‘composer_name’ please specify the corresponding module name which is indicated in your customer account.
Using Composer with multiple Amasty.com accounts and one Magento installation
There are seven Amasty repositories (for both Community and Enterprise editions):
They are completely identical, therefore you can add several of them using different Amasty.com customer accounts.
- composer config repositories.amasty_account1 composer https://composer1.amasty.com/community/
- composer config repositories.amasty_account2 composer https://composer2.amasty.com/community/
The way you name them, will not affect their behavior.
This way you will have two repositories added with different customer credentials. Using several Amasty repositories does not affect the way Сomposer commands are executed. In other words, say, to install the Improved Layered Navigation extension, please use the same command as usual: [php]composer require amasty/shopby[php]
What if I get ‘COULD NOT FIND PACKAGE’ error?
If you are trying to install a new mod with Amasty Composer, you can get an error that looks like this:
Could not find a matching version of package amasty/label. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (stable).
Or even something like this:
Failed: [Composer\Downloader\TransportException] 0: “https://composer.amasty.com/enterprise/packages/module-special-promo-pro-2.7.1-ee.zip” appears broken, and returned an empty 200 response.
Failed to download amasty/module-special-promo-pro from dist: “https://composer.amasty.com/enterprise/packages/module-special-promo-pro-2.7.1-ee.zip” appears broken, and returned an empty 200 response.
You can quickly manage this problem. Composer has cache. Clear it. It stores information about packages available in the Amasty repository. To clean the cache, use this command: [php]composer clearcache[php]
Usually, this action solves all the problems. Just try to add this mod again.
If you’re experiencing trouble with this way of Magento 2 extension installation, feel free to drop a line at firstname.lastname@example.org, we’d love to help you right away!
Do you have any questions about installation with the help of Amasty Composer? Feel free to ask them in the comments.