1

I've looked all over, but there seems to be no advice on this online.

I've recently updated a Drupal 8 site to Drupal 9. I wasn't using composer before, and so I've used composerize-drupal to make the site composer compatible.

I have my own custom module on the site, and I had to uninstall it to get the composerize-drupal and then the upgrade to work.

I'm now trying to reinstall it, but there is a complete lack of guidance on this coming up in google searches, and if I just upload it to the site as before, the site breaks.

Can anybody please help shed some light on how this can be done on a Compserized Drupal 9 site?

1

2 Answers 2

2

In composer.json you tell Composer in which directories it should put certain types of dependencies.

"installer-paths": {
    "web/core": ["type:drupal-core"],
    "web/libraries/{$name}": ["type:drupal-library"],
    "web/modules/contrib/{$name}": ["type:drupal-module"],
    "web/profiles/contrib/{$name}": ["type:drupal-profile"],
    "web/themes/contrib/{$name}": ["type:drupal-theme"],
    "drush/Commands/contrib/{$name}": ["type:drupal-drush"]
},

These directories are now managed by Composer. For example web/modules/contrib for type drupal-module dependencies. While at the same time everything put in web/modules/custom or any other custom location will be preserved.

Your repo in the end basically only contains the composer.json/lock files at the repo root and all custom code (custom themes, custom modules, custom scripts, custom patches etc.) and config YAML files in their desired directories.


You should gamble around a bit with the official recommended-project template or the community drupal-project template. Learn to read the composer.json file. Run composer install, manually delete certain directories, composer install again and observe what happens.

1

composerize-drupal creates the following directories for Composer dependencies:

  • [drupal-root]/modules/contrib
  • [drupal-root]/themes/contrib
  • [drupal-root]/profiles/contrib

By convention (or at least the convention I follow), custom stuff goes in a custom directory.

  • [drupal-root]/modules/custom
  • [drupal-root]/themes/custom
  • [drupal-root]/profiles/custom

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.