The release of Magento 2.0 took the open-source community by storm last year, and rightfully so. Along with a host of cool new features and powerful under-the-hood improvements, Magento revamped its look and and design, opting for a smoother, sleeker UI.
Any Magento installation is kinda incomplete without 3rd party extensions to optimize its functioning, and the same would stand true for Magento 2.0. Despite all the slick new additions, installing and configuring extensions on Magento 2.0 is still a tad bit complicated, and that’s where most users go treasure hunting for help. On the internet, or otherwise.This articles is not just intended to sail you through the A to Z of installing an extension on Magento 2.0, but also the possible hurdles you might on the way and how to best overcome them.
Extensions On Magento 2.0 – What’s New?
When you log into your Magento 2.0 installation, you’re greeted with a new and particularly well designed Magento dashboard. Naturally, you play around with it a bit, trying to figure what’s new and been done away for good.
It shouldn’t be long before you realize that the tool which helped you to install your Magento 1.xx extensions, Magento Connect Manager, is absent in the upgrade. With Magento 1.xx, any purchase that you made on Magento Connect would provide you with an extension access key.
This extension key was then used inside of Magento Connect Manager to install the extension.
Unfortunately, as convenient as this may have been, this procedure can no longer be replicated with your updated Magento installation.
Instead, with Magento 2.x you can install extensions using one of the following three ways:
- Using Magento Component Manager
- Using Composer
- Via Source code
Let’s take them up one at a time.
Installing Via Component Manager
Magento Component Manager, as the name suggests, is the de facto tool used for managing Magento components. That and it helps you to automatically sync your purchases on Magento Connect, and the ones on Magento Marketplace. Exclusively introduced in Magento 2.0.
The Component Manager is present under Web Setup Wizard. So now instead of obtaining and implementing an extension key to install an extension, all you would need to do is sync your purchase with Component Manager and install it.
- Entering the Magento Component Manager, you would be prompted to sign in.
- You need to enter your Magento Connect Secure Keys over here (applicable for both Magento Connect and Magento MarketPlace).
- To generate Secure keys, refer this document for detailed instructions.
- Once signed in, you should see the following screen:
- Clicking on the ‘Sync’ button will sync all your purchases on Magento Marketplace with your Magento site.
- As soon as you’re done syncing, you should see all your latest purchases listed under New Purchases.
- To install your purchases, click Install.
- You should see your purchases, listed out as:
- If you have multiple purchases, you can select all of them and then click Install.
Step 1: Readiness Check
Readiness Check checks whether your server environment is configured to allow installing additional extensions and upgrades. On install, you should see following screen:
During the Readiness Check, you might stumble across one of multiple issues. Here’s how you can deal with them and troubleshoot your way through the installation process:
For the CronTab Issue:
If you face an error at this check, then that’s probably your CronTabs are not set.
- Check if there is a Crontab or not. The code to do the same is:crontab -u <Magento file system owner user name> -l
- If there are no CronTabs, set them up as follows:
- Go to your magento root folder.
- Enter crontab -u <your magento_user> -e
- You might be asked to select a text editor. Select any of your choice.
- Copy the following lines of code and paste it into the Text Editor.* * * * * <path_to_binary> -c <ini_file_path> <magento_dir>/bin/magento cron:run | grep -v “Ran jobs by schedule” >> <magento_dir>/var/log/magento.cron.log * * * * * <path_to_binary> -c <ini_file_path> <magento_dir>/update/cron.php >> <magento_dir>/var/log/update.cron.log * * * * * <path_to_binary> -c <ini_file_path> <magento_dir>/bin/magento setup:cron:run >> <magento_dir>/var/log/setup.cron.log
- Replace <path_to_binary> with your binary file location.
- To find the location, run “which php”
- Replace <ini_file_path> with php ini file location.
- To find the file run location php -i | grep “Loaded Configuration File”
Replace <magento_dir> with your magento root directory path. For example,
Once you have done making changes save it and exit the editor. For more info, you can refer the relevant devdocs.
Updater Application Issue:
- It mainly happens if you don’t have the Updater application or you have not given proper permissions.
- Check whether you have “update” directory in your Magento root folder.
- If no then follow the instructions given in this doc. If there is a folder, then try changing the file and directory permissions.
- Here’s a link to the official documentation
Step 2: Create Backup
Once you have cleared the Readiness Check, hit Next. Before proceeding further, it’s advisable to back your site up, so that you can always roll back to a stable state in case of fatal errors. The site will be put on maintenance mode during this process.
For backup, select all the available options:
- Hit Create Backup.
- Once the backup is successfully created, you should see the following screen:
Make sure to clearly note the backup file locations.
Step 3: Component Install
This is where Magento informs you about the components you are about to install.
- Hit Install.
Once all the components are installed, you should see the following message.
Job done. Your new Magento Extension has been installed.
Installation Via Composer
What happens when you’re dealing with extensions that you obtained outside of Magento Marketplace? You install them via Composer.To find your way through this method of installing Magento extensions, you’d need to get your hands into the command line. Most developers prefer using the Composer Repository.
- If your server supports composer, only then will this method will work.
- For demo, we have used this extension: The installation steps are given on the GitHub, but let’s explore these steps and find out what is happening underneath the hood.
Step 1: Disable the Cache
- Magento is heavily reliant on caching to provide for a smoother and faster user experience.
- As wonderful a tool as it is, caching is known to cause severe issues while installing extensions using this method, so it’s advisable you switch caching off.
- This can be done from the admin console by navigating to the Cache Management page (System->Cache Management), selecting all caches, clicking “disable” from the drop-down menu, and submitting the change.
Step 2: Installation
- Go to Magento root folder and execute,
- The next step is to load the correct branch as dependency.
- Execute “composer require inchoo/stripe:dev-master”.This step will basically add our new package to the composer.json file present in the current directory i.e Magento root directory. And install it as dependency.
- Next step is to enable the module and clear the static content present.
- Execute php bin/magento module:enable Inchoo_Stripe –clear-static-contentYou should see the following output. The above command will add the module to the modules list in app/etc/config.php.
- After that execute: php bin/magento setup:upgradeThis step installs the module.It basically triggers setup scripts of all Magento modules that needs setup, but if you just enabled one new module nothing else will execute except that one.
- Once the upgrade command has executed successfully, you will see a message like:
- Execute: php bin/magento setup:di:compile
- Let the compilation complete.
- That’s it you are done.
- You can now setup your extension through Magento dashboard.
Manual Installation Via Source Code
- While browsing for extensions, you will find many websites where developers have given the source code of extensions, mostly on GitHub repositories.
- Following are the installation steps for those extensions:
Step 1 : Understand the Source Code Directory StructureFirst up, you’d need to understand the directory structure of the Source code that you downloaded. For demo let’s take Directory structure of this image slider. Once downloaded, you will see the directory structure as “app/code/Ves/…”
- If you go and check your Magento root directory structure, you will find the following directory structure: /app/code/…
- By comparison, you might be able to identify that the Ves folder from the extension source files needs to go in the /app/code/ directory of magento root.
- Copy the Ves folder and paste it in magento-root/app/code/
- Once you have the source code in place, you need to upgrade the magento, so that it installs the new extension. Command: php bin/magento setup:upgrade
- Next you need to deploy the static view files that were generated in upgrade process. Command: php bin/magento setup:static-content:deploy The static view files deployment command enables you to write static files to the Magento file system.
That’s it. You are ready to go and set up your extension from the Magento dashboard.
Still need assistance with installing a rogue extension? Let us know any issue that may face in the comment section below, or Talk to a Magento Expert now to get the job done quick and hassle free!