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:
- Copy these files into app/code
- Copy this zip into folder, add it is a artifact repository, and require it
- 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.
Best Answer
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 runcomposer 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
In my opinion composer is the best and proper way to install module in Magento 2.
Install Third Party Module Via composer:
setup:upgrade
to install and register module inconfig.php