4

I'm developing a set of site-specific custom modules, and one of them depends on the other one being enabled.

I'd like to declare this dependency in the .info.yml file, but the docs only show how to declare dependencies on contrib projects:

Dependencies should be namespaced in the format {project}:{module}, where {project} is the project name as it appears in the Drupal.org URL (e.g. drupal.org/project/views) and {module} is the module's machine name.

How do I declare a dependency on a module that is only found in the local codebase?

1
  • When creating the namespace of your custom module be sure to avoid those used by projects that are hosted at Drupal.org. As you may have noticed a single project download from Drupal.org may include a few modules. for example the 8.x Chaos tool suite (ctools) project contains three modules: Chaos tools, Chaos tools blocks (Experimental) and Chaos tools Views (Experimental). A dependency of ctools:ctools_block allows you to require the Chaos tools blocks module from within the project. You can also see this when requiring a module from core - drupal:views_ui Aug 28, 2018 at 16:07

2 Answers 2

11

Try this just like contrib projects.

dependencies:
  - your_module_name
1
  • 1
    If your project name and module name are the same you can use the shorthand as shown above. Aug 28, 2018 at 15:50
1

Below is the more specific answer to load specifc library

dependencies:
  - <your_module_name>/<library_name>

Hope this gives an idea to load a specif library from the list of libraries in *.libraries.yml file

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.