2

I have a problem with dependencies in my custom module.

I'm using drupal-composer and I'm able to install my own module with the composer.json. My module comes from custom Git repository.

At this moment, though, I'm unaware of any working way to get my custom modules dependencies installed at all. I can add them one by one to the composer.json, though they do not appear into right namespaces after that, but let's just disregard that because I would really like to be able to specify them into my custom module and get them installed automatically. This is because I will be having multiple modules with multiple dependencies. Also, some of these dependencies will be from my own repositories, but that should not make any difference. And to be specific, at this point I'm trying to add a custom git repository containing some PHP source files that I need for the services exposed from my modules.

I have also tried installing modules from Drupal packagist and their dependencies are all nicely downloaded.

So is there any way to specify these dependencies into my own module and how to get them working? I have added them to my modules composer.json, but that does not seem to have any effect. They also need to be there when I run my PHPUnit tests.

Also I'm aware of the composer-manager plugin for Drush, but at this point, (due to other requirements) it is not an option.

1

Ok, seems to me that I almost got it.

This was due to my repository list in the Drupal root composer.json. I had this kind of thing there:

{
  "type": "package",
  "package" : {
    "name": "blaah",
    "version" : "xxx",
    "type":"drupal-module",
    "source": {
      "url": "gitblaag",
      "type": "git"
    }
}

That some how seems to override what ever is in the modules composer.json. I do not really know why but something along the lines that the entry defines the whole package and no more info will be read from the composer.json in the module.

So I adding "require" there does the magic. Also probably removing some of those lines and making it just a repository, not a package, would result into composer reading the individual modules composer.json.

But now everything seems to be right and module is installed and it will install my other files under vendor but PHP still goes to "class not found" in my service when I try to use my class from the other library.

  • And the class not found magically resolved itself. Great :) Now I'm trying to only put the git repositories on the repository list and then get the composer to read the actual composer.json files from the repos. – user2637046 Apr 15 '16 at 14:11

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.