As a module maintainer, I would like to support the move/push for using composer in Drupal. We have documentation that explains how I can add a composer.json file - "A composer.json file can be added to your module to define the project itself."

The question is if we should recommended it, if the module doesn't have any external dependencies. Reasons against it:

  • Installing such modules using composer (through the https://packages.drupal.org/ repository) currently works without creating a composer.json file
  • A minimal composer.json file just duplicates information that is found in the info.yml file - and duplication is bad.

So, at one hand I like the idea that all modules have a composer.json file. On the other hand, it seems like wasted effort and a potential source for errors, for modules with no external dependencies.

Any thoughts?

PS! Please move this issue, if there is a better location for it.

Comments

hansfn created an issue.

aimevp’s picture

Would the presence of a composer.json solve the issue (in some cases) where composer doesn't download the most recent version of that module.

I recently experienced the problem with "Chosen" and "Views Reference Field" where I was unable to download/specify the version I wanted to install.

Or has the presence of composer.json nothing to do with the issues I've experienced with those modules?

Btw, today I finally found a workaround by defining a new repository using it's GIT url but I'm guessing that's not a great practice. This is the composer code I ended up using (just replace custom name with whatever you want):

"viewsreference": {
            "type": "package",
            "package": {
                "name": "<my custom name>/viewsreference",
                "type": "drupal-module",
                "version": "dev-master",
                "source": {
                    "type": "git",
                    "url": "https://git.drupal.org/project/viewsreference.git",
                    "reference": "8.x-1.x"
                }
            }
        }

And call it with:

composer require <my custom name>/viewsreference