0

Is it possible to add repositories from a module's composer.json instead of a project's composer.json? I've got the following set up:

I'm developing Commerce Recurly and am declaring a dependency on the Recurly module. However, the Recurly module uses API v2, and I am using API v3 in Commerce Recurly. Since the namespacing of the two APIs are different there are no conflicts when running them concurrently, so I created a fork of the API v2 to allow both to be added to my project. The result is that I am able to get both recurly/recurly-client and mrweiner/recurly-client-php-v2 concurrently installed to vendor.

Composer picks up all of the require dependencies correctly from both modules' composer.json files, as well as the patches from the Recurly Fork. It doesn't seem to pick up the repositories sections, though.

I'd expect to be able to just add the Commerce Recurly repo to my project's main composer.json like so and have everything install when running composer require sandbox/commerce_recurly:

    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "commerce_recurly_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131465"
        },
    }

This doesn't work, though. I need to add repository entries for all three repos to my project's main composer.json to get composer require sandbox/commerce_recurly to correctly install everything, like so:

    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "commerce_recurly_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131465"
        },
        "recurly_fork_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131471"
        },
        "recurly_api_v2": {
            "type": "package",
            "package": {
                "name": "mrweiner/recurly-client-php-v2",
                "version": "2.12.13",
                "type": "vendor",
                "source": {
                    "url": "https://github.com/mrweiner/recurly-client-php.git",
                    "type": "git",
                    "reference": "c9f67565"
                }
            }
        },
    }

Is there some way to get composer to pick up the repositories defined in the modules' composer.json files? Having these extra entries isn't a huge deal for me right now, but when I move Commerce Recurly from Sandbox to a full project, it's going to be inconvenient to force people to add extra Repos to get things running.

  • 1
    Nope, you reached a dead end: getcomposer.org/doc/faqs/… This is a hard limitation of composer, you must add foreign repos in your root composer.json – Hudri Apr 28 at 8:13
  • 1
    Have a look into Satis - rolling your own package server is surprisingly easy, and potentially a more elegant/robust solution for your problem – Clive Apr 28 at 11:05
  • Thanks @Hudri, that's the info I was looking for but couldn't find. Bummer, but I kind of figured as much. – Mrweiner Apr 29 at 3:07
  • @Clive thanks for the tip, I'll check it out. – Mrweiner Apr 29 at 3:08
0

Comments above pretty much answer this. No what I was looking to do is not possible.

| improve this answer | |

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.