Magento 2 Developement

How to install magento 2 module from github using composer

Install magento 2 module from github using composer is pretty simple. We assume that you already has git and composer installed on your system. Let’s take magento2-configuration-arrayserialized as an example. Complete commands list are:

composer config repositories.elpas0-magento2-configuration-arrayserialized git git@github.com:elpas0/magento2-configuration-arrayserialized.git
composer require elpas0/magento2-configuration-arrayserialized dev-master
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean

Explanation

Register the repository

composer config repositories.elpas0-magento2-configuration-arrayserialized git git@github.com:elpas0/magento2-configuration-arrayserialized.git

First we add our repository to project composer.json file. Command syntax

composer config repositories.  

It will add our repository to repositories section of magento json file. Updated section looks like

"repositories": {
        "0": {
            "type": "composer",
            "url": "https://repo.magento.com/"
        },
        "elpas0-magento2-configuration-arrayserialized": {
            "type": "git",
            "url": "git@github.com:elpas0/magento2-configuration-arrayserialized.git"
        }
    },

More information about composer config command can be found here – https://getcomposer.org/doc/03-cli.md#config

Download module files

composer require elpas0/magento2-configuration-arrayserialized dev-master

It will register module in require section of composer.json and download the files from repository

Module installation

php bin/magento setup:upgradeUpgrades the Magento application, DB data, and schema
php bin/magento setup:static-content:deployDeploys static view files
php bin/magento cache:cleanCleans cache type(s)

Quick links

Magento 2: How to disable module
Magento 2: How to uninstall module
Magento 2 Command-Line Interface (CLI) Commands List

Leave a Reply

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