Thomas Crawford
Thomas Crawford

Reputation: 896

Drupal 8 Module Development Dependencies

I want to create a new drupal 8 module. I also need an composer package to make this module.

In the root of drupal 8 i already have a composer.json file.

So ofcourse i can add the needed dependency/package to that root composer.json file.

But when someone else want to download my module for example, they don't have that dependency installed.

What is the best way for making sure that when someone downloads my module, the dependencies are available for them?

Many thanks

Upvotes: 2

Views: 348

Answers (1)

Aless_io
Aless_io

Reputation: 96

Just create a composer.json file in the root of your module with all the dependencies you need:

{
  "name": "drupal/my_module",
  "type": "drupal-module",
  "description": "Description of my module",
  "keywords": [
    "Drupal"
  ],
  "license": "GPL-2.0+",
  "homepage": "https://www.drupal.org/project/my_module",
  "minimum-stability": "dev",
  "support": {
    "issues": "https://www.drupal.org/project/issues/my_module",
    "source": "http://cgit.drupalcode.org/my_module"
  },
  "require": {
    "lib/libname": "0.6.*",
    "lib2/libname2": "dev-master",
  }
}

Then make it available through drupal.org or other packages managers like gemfury and just run:

composer install drupal/mymodule

Upvotes: 2

Related Questions