Problem/ Motivation
As part of the Drupal 8 port, we want to make sure that Composer Manager handles our dependency of the Mobile_detect library.
Solution
Write a patch to integrate the dependency from Mobile_detect.
Here are great documentation on how to integrate Composer Manager with Drupal 8 .
Here is the Mobile_detect library in the packagist - https://packagist.org/packages/mobiledetect/mobiledetectlib
Here is some usefull information about composer.json https://getcomposer.org/doc/04-schema.md
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 2627482-interdiff-8-9.txt | 338 bytes | darol100 |
| #9 | 2627482-Integration-with-Composer-9.patch | 1.37 KB | darol100 |
Comments
Comment #2
darol100 commentedI will give this a shot, assign it to myself.
Comment #3
darol100 commentedHere is the first patch. To test it out you need to run
composer drupal/mobile_detectinside of the project. This will download the mobile_detect library with composer.In the future, I think we should add the hook_requirements to make sure that this project can not be install unless we have the library. What you guys think about this ?
Here is an example of hook_requirements from the address project.
Maybe we should wait until we have a class from #2627514: Create a service to load the Mobile_Detect library and they implement the hook_requirements
Comment #4
jmolivas commentedI test the
composer.jsonfile:Using:
composer validateAnd got a valid output:
./composer.json is validComment #5
darol100 commentedThe current patch from #3 will save the Mobile_Detect library into a vendor directory inside of the module. My question should we make this available in to the vendor directory or some place else where the code can be reuse just in case ? Similar of what libraries api where we use to add things on sites/all/libraries.
Comment #6
mpdonadioComposer Manager will search out composer.json files in modules and add them to the root composer.json via the merge plugin. A `composer drupal-update` will then install everything. What the address module does is a good model. See also https://bojanz.wordpress.com/2015/09/18/d8-composer-definitive-intro/
Comment #7
darol100 commentedI had the same conversation with @Crell and other people in IRC. I did not that composer manager did that.
@mpdonadio, Do you think we need to add this extra composer information ?
I took this code from https://bojanz.wordpress.com/2015/09/18/d8-composer-definitive-intro/
Comment #8
darol100 commentedI use the devel composer.json and the address composer.json as an example and re-roll the entire patch with more useful information. Also, I fix the license because I thought that the license was base of the library and it should be base of the project. I can confirm that the patch have been validate if I run
composer validate.Also, if I install and configure composer_manager and run composer drupal-update it download the library into the root vendor directory.
I do not think none this is need it.
Comment #9
darol100 commentedRemoving this ...
From #8 patch because is not need it.
Comment #11
darol100 commentedI push #9 patch into the 8.x branch. So we can start moving on with other patches that are dependent on this patch.
There does not seem to be like a real example on how to use a composer.json with Drupal 8 on Drupal.org documentation pages. There are little of information all over the place.
I ended up doing couple things with this patch:
I'm going to leave as "Needs Review" and assigned it to @mpdonadio for one last review just in case you will like to change something.
Comment #12
darol100 commentedI have to change the title because ... I do not think this is necessary directly with "Composer Manager" instead to Composer. I have pushed this into the 8.x.2 branch.