0
votes

I have been working through the guidance available at: https://www.drupal.org/docs/creating-custom-modules

I added my custom module to my composer.json, like so:

composer config repositories.mygit \
  '{ "type": "vcs", 
     "url": "git@git.mydomain.com:cf_supporters_for_drupal.git",
     "ssh2": { "username": "git", 
               "privkey_file": "/var/lib/jenkins/.ssh/id_rsa",
               "pubkey_file": "/var/lib/jenkins/.ssh/id_rsa.pub" } }'

composer require ymd/cf_supporters_for_drupal

in the path with my composer.json file, I run:

drupal$ find . -name cf_supporters_for_drupal
./vendor/ymd/cf_supporters_for_drupal

browsing to it, using git status and git log I have determined that I have the newest version installed.

And yet, I see no evidence in the /admin/modules path that the module is available to me. I'm curious about how I might begin to debug this issue. Can anyone provide any guidance beyond what I already see at: https://www.drupal.org/docs/creating-custom-modules/let-drupal-know-about-your-module-with-an-infoyml-file#debugging ???

~/sandbox/cf_supporters_for_drupal $ cat cf_supporters_for_drupal.info.yml 
name: CF Supporters for Drupal Module
description: Exposes the cf_supporters_mojo application on a drupal web site.
package: Custom
type: module
version: 1.0
core: 8.x
configure: cf_supporters_for_drupal.settings

~/sandbox/cf_supporters_for_drupal $ cat composer.json 
{
    "name": "ymd/cf_supporters_for_drupal",
    "description": "A drupal module to expose cf_supporters_mojo",
    "type": "module",
    "license": "GPL-2.0-or-later"
}

~/sandbox/cf_supporters_for_drupal $ tree . 
.
├── cf_supporters_for_drupal.info.yml
├── cf_supporters_for_drupal.links.menu.yml
├── cf_supporters_for_drupal.routing.yml
├── composer.json
├── LICENSE
├── README.md
└── src
    └── Controller
        └── CFSupportersForDrupalController.php

2 directories, 7 files

UPDATE #1:

2pha, in a comment below, suggests I need to put this code in a modules folder, rather than simply in the vendors folder. My questions back in 2pha's direction are:

I assume I want to put it perhaps in web/modules/custom ??? Is that right? How is it, using the composer config cli tool (I need to script this as much as possible), would I make that happen?

1
your module must be in the modules folder for drupal to detect it - 2pha
I assume I want to put it perhaps in web/modules/custom ??? Is that right? How is it, using the composer config cli tool (I need to script this as much as possible), would I make that happen? - Hugh Esco
Did you start the project by using drupal/recommended-project? If so, you will see it have installer paths set in the composer file, specifically different "types". type:drupal-module installs to web/modules/contrib/{$name}, type type:drupal-custom-module installs to web/modules/custom/{$name}. This "type" is set in your modules composer.json - 2pha

1 Answers

0
votes

Yes, thank you, 2pha!

Late last night, I found documented here: https://github.com/composer/installers

that composer has built in support for fourteen drupal-specific 'types', including: 'drupal-custom-module'. I have not (yet) found a way using composer config to manipulate extra.installer-paths hash in composer.json. But doing so manually as you suggest above, resulted in exposing my module on the /admin/modules and the /admin/config pages. For the moment that is close enough that I have now turned my attention to creating a configuration page for my module.