Install Dependencies for Manually Installed Modules – Magento 2 Guide

composerextensionsmagento2

We are setting up a Magento 2 store using Composer to manage packages whenever possible. This is working great for us, except that some third-party extensions we have purchased are not available to install via Composer. They require the extension to be manually copied into app/code.

However, at least one such manually-installed extension required a separate open source library that was not bundled with the extension. This dependency was specified in the extension's composer.json file, but since the extension itself wasn't installed through Composer, it was not picked up by composer update.

Thus the question: is there any way to have Composer inspect the dependencies of manually installed extensions living in app/code? If not, is the best approach here to simply copy & paste any dependencies into the main project composer.json? That's pretty inelegant.

One solution would be to create our own private repository for each of these third-party extensions and then install them via Composer, despite the vendor instructions. We may eventually adopt that approach, but I'm wondering if there are other options.

Best Answer

If not, is the best approach here to simply copy & paste any dependencies into the main project composer.json? That's pretty inelegant.

Yes, given that the extension is manually copied to app/code, this is the best approach, and yes, this is pretty inelegant.

The real best solution is to not copy the extension manually. It already has a composer.json file, so you can install it with composer. Set up a private repository (for example at Bitbucket or on the local filesystem outside of the Magento root), specify it in repositories of your composer.json and then require the module as any other composer module.