0

I want to ask a theoretical question.

For example, there is a project on Drupal 8. Working on the project, developers find a php library on the GitHub, include it via Composer and use it in their modules.

They don't create drupal 8 module which would present the library and contain files of the library, copied from GitHub before. And to use the library it would be necessary to install the module.

Is it the correct way to attach an external php library via composer and afterwards use it without creating a module for Drupal 8 for this library ?

1
  • yes, that's how composer works.
    – user21641
    Sep 8, 2017 at 17:14

1 Answer 1

0

Sure, you can do that on a project.

But you're probably going to write code somewhere to actually integrate that into Drupal and expose it somehow, and that will be in a module (or theme). But especially if that's a custom module that is just used for that site, you kind of have to add it to the project composer.json as composer doesn't include composer.json of moules that aren't actually added themself with composer (excluding solutions like merge plugin)

2
  • No, working on Drupal 8 project I have found a php-library, which can solve my tasks. And I wrote it in the composer.json as "required" and atter it updated the composer. Now I use classes from the library in my project. I'm interested, is this way correct ? Sep 8, 2017 at 18:15
  • As you said, you use those classes somewhere, which has to be in a module or theme. Which, as I said, is perfectly fine
    – Berdir
    Sep 8, 2017 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.