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 ?

  • yes, that's how composer works. – user21641 Sep 8 '17 at 17:14
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)

  • 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 ? – Yakimkin Roman Sep 8 '17 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 '17 at 18:58

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.