17

While working on a client project for Magento 2 - I've discovered numerous methods of loading in and keeping track of third party extensions.

Going into this assuming that we're using the integrator installation method (composer!), what are the best practices for managing third party extensions?

So far, every extension I've purchased or downloaded has had it's own composer.json file - and I know of at least three different ways extension authors would recommend to install their extension:

  1. Copy these files into app/code
  2. Copy this zip into folder, add it is a artifact repository, and require it
  3. Add this online repository (with/without auth) and require it

So far, I've come across 1 & 2 and am just sort of suspecting #3 exists. But then, noticing that the ones that suggested #1 I found that you can have a "path" repository - moved my extensions from app/code to the same folder I decided to put these artifacts, and required it that way.

In this process, my repositories configuration looks something like:

"repositories": {
    "0": {
        "type": "composer",
        "url": "https://repo.magento.com/"
    },
    "artifacts": {
        "type": "artifact",
        "url": "artifacts"
    },
    "third-party": {
        "type": "path",
        "url": "artifacts/*/*"
    },
},

So my question to you is - what is the best practice here? How do you manage third party extensions?

So far I believe the way I am doing it is the best way - if only because their composer.json gets read and any dependency conflicts (or PHP version constraints) will become apparent - but I don't think that's definitive enough.

5 Answers 5

11
+50
  • Install module via composer is the best way to Magento 2. Becuase there are many advantages if we install module via composer.

  • If you want to upgrade module you just need to change the version in composer.json file and run composer update command at the rootMagentoento.

  • While in manual installation you need to first download module and replace old files and run setup:upgrade command to upgrade module.

  • All modules which are installed via composer are downloaded in vendor folder.

  • Magento uses default https://repo.magento.com/ URL to download module If you purchase module from Magento Marketplace.

  • If you purchase module from third-party website. You need to add a repository in composer.json to download and install a module.

For Example

"repositories": {
    "0": {
        "type": "composer",
        "url": "https://repo.magento.com/" //Default Magento Repositry
    },
    "thirdparty-module": {
        "type": "composer",
        "url": "https://mymodule.thirdparty.com/" //Third Party Repositary
    }
},

In my opinion composer is the best and proper way to install module in Magento 2.

Install Third Party Module Via composer:

  1. Run this command to add new repository in conposer.json

composer config repositories.thirdparty-module git https://thirdparty-composer-url.com

  1. Now run this command to add component and version of module in composer.json

composer require [component-name]:[version]

Forex.  composer require prince/helloword:1.0.0
  1. Now run composer update to download module from repository.

composer update

  1. Now run setup:upgrade to install and register module in config.php

php bin/magento setup:upgrade

1
  • Agree! Use of composer gives you an architecture to manage your installed versions of code, check for updates, easily add/remove modules, upgrade, downgrade etc. This all assumes of course that the software vendor supplies access to the composer based software package online. This is MUST for all vendors! Dec 7, 2020 at 19:48
2

Weirdly all of the answers miss the point that you have identified the artifacts as one possibility:

https://getcomposer.org/doc/05-repositories.md#artifact

Module supplier(s) might not have a repo that you can use so artifacts is answer. Majority (that I have run across) will give you a zip package for the files so using that with composer via artifacts IMHO is the most easiest way.

Of course you can feature your own repo for the 3rd party modules files but personally I don't see the point on going the extra step on those.

Thought it is worth to mention if you add them to the app folder and commit the files, or with your own repo you can easily spot what files have changed between versions of the 3rd party extension.

Anyways I found this article on using the arficats https://magently.com/blog/magento-2-the-right-way-to-install-external-modules/ so others are using that flow also.

-1

There are two ways of doing it, Please find these below.

(1) Automatic Installtion using composer

Purchase of download product from marketplace and check component's name from downloaded product information and use below example code for updating composer.json file in application root.

Note: Don't forget to include composer.lock file to include in your git commit.

Official Reference: http://devdocs.magento.com/guides/v2.0/cloud/howtos/install-components.html

(2) Manual Installation

Download component zip file from your downloads and unzip at temporary location and check it's registration.php file, there you will see compoent vendor name and component name. Create similar directory structure inside.

app/code/VendorName/ComponentName

Extract your zip file inside above directory structure and run below commands from your application root directory for enable the module.

php bin/magento module:enable VendorName_ComponentName
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush
php -R 777 var/

Check module is enable using below command. It will show all enabled and disabled modules list.

php bin/magento module:status

Hope this helps!

1
  • I didn't found correct answer yet., though got more confused on this. Dec 30, 2017 at 10:32
-2

I have installed extensions for magento2 by placing the extension under app/code and the website have been working good for me, so installing them by placing extension under app/code is one of the way to install extensions!

-2

Best practice to managing the third party extension is to Download the zip file and import the zip inside app/code folder and unzip it.

After that use following commands

  1. php bin/magento module:enable _
  2. php bin/magento setup:upgrade
  3. php bin/magento setup:di:compile
2
  • Be warned: This is NOT a best practice. Installing modules via app/code is not to be recommended over using composer. Use composer instead. Jun 24, 2018 at 7:56
  • Agree! Use of composer gives you an architecture to manage your installed versions of code, check for updates, easily add/remove modules, upgrade, downgrade etc. This all assumes of course that the software vendor supplies access to the composer based software package online. This is MUST for all vendors! Dec 7, 2020 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.