3

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.

  • 1
    You could try the composer merge plugin: github.com/wikimedia/composer-merge-plugin. That might work for what you are trying to do. – dmatthew Mar 8 '17 at 0:50
  • Thanks @dmatthew. I'll take a look at that. I was hoping for something more automated, but maybe this can be automated. – Scott Buchanan Mar 9 '17 at 0:08
3

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.

  • Thanks for the confirmation. Yes, as I noted in my question, I was aware of the private repository route, but it's a bit of a hassle. I guess it is the "right" answer. It does seem, though, like it should be possible to make Composer look at the composer.json files inside app/code as if they were inside vendor. Maybe I'll submit a PR to magento/composer for that. – Scott Buchanan Mar 9 '17 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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