SwiftERM logo
SwiftERM logo
How to install modules manually - Magento2

How to install modules manually – Magento2

Here are the two ways that modules can appear in the system:

Magento 2 gives you an opportunity to manually install modules using 3 different methods: via composer, via ZIP-archive, and via your browser. The choice of a method depends on the way that a module appeared in the system. Let’s consider each of these in detail.

You have 2 access keys, generated in your Marketplace account.

  • If Magento is correctly configured, you can add these keys to the Magento admin panel. It is synchronized with your Magento marketplace account, and you can manage the installation of any purchased packages there.
  • If you are an advanced user and can use the server console, you can install a module via the composer. You will also need to enter the keys if they were not previously saved in the system.

A module is installed from third-party sources.

  • You can get it in the form of an archive.
  • You can be given a link to a third-party repository, e.g.: GitHub. Installation from it can also be done via the composer.

Now let’s take a closer look at each method of module installation.

Generating “Access Keys” in a Magento account

You can log in or create a new account at magento.com. After that click on the “Marketplace” link in your account.

How to install modules manually in Magento2

Or go directly to the Magento extensions store.

How to install modules manually in Magento 2

In “My Profile” we are looking for the “My Products / Access Keys” section. You just need to generate the necessary keys.

How to install modules manually in Magento 2

Installing modules via Composer

This is a way for you if you know how to use the server console.

The composer is a file called composer.phar. You can download it at getcomposer.org. It is launched from the Magento root directory. The folder should contain the composer.jsonfile with the configuration of the installed libraries.

php composer.phar

If the composer is installed globally on the server, there is no need to download it and you can refer to it in the following form:

composer

  1. If the module is distributed from the Magento repository, we can just run the following commands:

php composer.phar require [vendor]/[package]

php bin/magento setup:upgrade

And they will do the rest of the job.

  1. Or it could be a module from a third-party repository and we will need to specify it in the composer.json file.

We are interested in the “require” part, where we indicate the name of the module that we add.

12345678{   . . . . .   “require”: {        . . . . .   “vendor/package”: “version” }, …..}

If the third-party repository is, for example, GitHub, you will need to specify it in the “repositories” branch.

1234567891011{   . . . . .   “repositories”: {        . . . . .        {           “type”: “git”,           “url”: “https://github.com/ . . . . .”       }   }, …..}

Usually, all this data is provided with the module.

Next, after saving the file, run the following commands:

php composer.phar update [vendor]/[package]

php bin/magento setup:upgrade

For example, let’s take a look at the installation of one of our free modules. It is located in the GitHub repository. Since the module is not installed from the Magento repository, we’ll add it to the composer.json file.

1234567891011{   . . .   “repositories”: [       . . .       {           “type”: “vcs”,           “url”: “https://github.com/belvg-public/Magento2_ApplyTo”       }   ],   . . .}

And apply our module there:

1234567{   . . .   “require”: {       . . .       “belvg/module-applyto”: “dev-master”   }}

It only remains to start the updating process. The necessary modules and add-ons will be downloaded according to the changes that were made to the composer.json file.

php composer.phar update

Then start the installation of all the new modules in Magento.

php bin/magento setup:upgrade

Installing modules via ZIP-archive

When you wonder how to add the extension in Magento 2 firstly you should copy it’s code to the required directory:

How to install module manually on Magento 2

The left panel shows here the basic listing of the zip-file with a module.

The right panel — Magento 2 codebase.

Current zip-file contains User_Guide.pdf file and the Install directory. Basically, the Install folder content should be copied to the app/code/ directory.

After that, we can use 2 different methods to initialize the module in a store.

Installing modules via a browser

This method requires Cron tasks set up and proper running. In case it has not performed yet — do it. You will need it further, not only while extensions installing.

So if Cron is set up correctly, just follow the path in admin panel to initialize the module:

System/ Web Setup Wizard/ Component Manager

Here you can enable all available modules.

How to install module manually on Magento 2

In case Magento is set up properly you’ll see the notification that all of the systems run correctly.

How to install module manually on Magento 2

Further, before you enable the custom module in Magento 2, Backup creation will be proposed.

And finally, we will see the following screen:

How to install module manually on Magento 2

The module has been enabled. And now we can switch back to the module list and enable (install) the next one.

Console commands in Magento

You have already met one of them:

php bin/magento

Magento CLI provides a large number of useful console commands to manage the store. And you can get the list of these commands by running: php bin/magento.

How to install modules manually - Magento2

But now we need to use only one:

php bin/magento setup:upgrade

This command checks all of the modules and launches schema installation or updating process (if necessary). So you just need one command to perform updating and installation of all modules.

The rights to the files

For greater security (or for other reasons), the server can be configured so that the installation of the modules is performed by a specific user.

In this case, when executing console commands:

php composer.phar

php bin/magento

there may be reports of insufficient rights.

You can try running the same commands on behalf of another user or simply from the administrator. For example:

sudo -u php bin/magento

or simply

sudo php bin/magento

Also, you may need full rights for some folders. For example, when installing modules, you may not have access to some files from the app/etc directory.

chmod 777 app/etc

chmod 644 app/etc/*.xml

Or to the var folder containing a lot of temporary files, and the rights to which should be distributed to all subdirectories (the -R parameter is recursive).

chmod -R 777 var/

Other occurring mistakes

When installing a module via the composer, one of the errors that you may face will be a mismatch of PHP versions.

Another issue is the dependency of the module being installed on libraries (of other modules), which for some reason the composer cannot automatically find and load together.

The correct thing to do will be to study and edit the composer.json file and to set all the versions correctly in it.

The same file can be located inside the module and you may need to change the version of the library to be pulled along. Or find and edit other changed data.

But you may also ignore the settings in this way:

composer update [vendor]/[package] —ignore-platform-reqs

Share :

Leave a Reply

Your email address will not be published. Required fields are marked *