0

I’ve come across several Drupal7 modules that include a composer.json. It seems that this somehow influences how Drupal-CI determines test dependencies. Now I’m trying to find out whether it’s worth providing a composer.json at all in Drupal7 modules/themes maintained by me. I couldn’t find any hard facts about what exactly can be achieved by providing a composer.json, that’s why I’m looking for pointers to …

  • How does the presence of a composer.json affect processing in the Drupal-CI?
  • What other functionality is enabled by providing a composer.json file for Drupal7 modules (or themes)?

Note: There seems to be a lot of documentation about Drupal 8 / composer, but nothing specific for Drupal 7 / composer.


Here is a list of some Drupal7 modules with a composer.json:

  • currency: Specifies exclusively non-Drupal dependencies.
  • raven: Specifies exclusively non-Drupal dependencies
  • stringoverrides: Only package metadata, no dependencies.
  • 1
    Comment on the close vote: I’m not interested in opinions — only about hard facts: What is technically enabled by providing a composer.json as opposed to not having one. – zwirbeltier Sep 6 at 16:50
  • You need a composer.json when you need additional dependencies. What are the other composer.json you are referring to doing? – leymannx Sep 6 at 17:08
  • They are exclusively specifying non-Drupal dependencies it seems (currency, raven). – zwirbeltier Sep 6 at 17:22
  • Can you maybe link these modules in your question? Maybe it helps to narrow things down a bit. – leymannx Sep 6 at 17:34
  • @leymannx: Good idea. I have added a list of modules to the question. – zwirbeltier Sep 6 at 18:02
1

I wrote a blog that gives some case studies about when and why you would include a composer.json with your module: https://www.morpht.com/blog/drupal-and-composer-part-4-composer-drupal-developers

Basically it comes down to four things:

  1. It allows your module to be managed with composer.
  2. It allows your module to have it's Drupal module dependencies managed by composer
  3. It allows your module to have it's 3rd party library dependencies managed through composer
  4. Composer handles autoloading of namespaced classes in libraries it manages, meaning your module can use the 3rd party libraries it depends upon, without having to include any files

If none of the above requirements match your needs, then there is no reason to have a composer.json file in your module.

  • Which of these apply to D7? – zwirbeltier Sep 7 at 5:56
  • None of those are Drupal version specific, meaning they apply to any Drupal version, including seven. – Jaypan Sep 7 at 6:23
  • Edit: Though Drupal 6 modules on Drupal.org probably don't have composer.json files, and therefore Drupal 6 modules couldn't manage their dependencies with composer.json. – Jaypan Sep 7 at 6:42

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.