1

I'm writing a new module which has a dependency on an external library. In Drupal 7 I would use hook_libraries_info giving the name of the library the required assets and Drupal would search the valid locations, libraries directories, to load these assets when required. Drupal 8 introduces *.libraries.yml and after reading https://www.drupal.org/node/1996238 it seems that module developers must now provide a path, relative or absolute, to the required assets.

In my case I will be expecting site builders to download the external library - where should libraries be located in Drupal 8?

  • I think the best answer is going to vary depending on frontend library (JS/CSS) versus backend library (PHP). – mradcliffe Nov 14 '15 at 16:34
2

hook_libraries_info is not in core, it is from a contrib module:

Libraries API

This module provides the external libraries. It will be ported to drupal 8 and can be used the same way as in drupal 7.

In drupal 8 the libraries, that are defined in *.libraries.yml are seperate and should not be confused with the external libraries, despite their identical name. They are mainly for js and css packages, that are specific to one module, but can also be used by other modules. They can be a replacement for the external libraries, but do not provide the full functionality.

In the long run composer will probably be the way module developers will go for downloading external libraries. But for now this is an ongoing discussion how this can be implemented.

Your reference to https://www.drupal.org/node/1996238 is a seperate issue about the replacement of hook_library_info() in drupal 8 core. This must not be confused with the external libraries defined in hook_libraries_info().

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.