2

I'm working on Open Atrium 2 and we'd like to include Guzzle with the initial install so that we can build some integration features on top of it.

Usually, including a library just means adding the library to the drush make file, but Guzzle is more complicated because:

  1. it has a few dependencies.
  2. it's meant to be installed by Composer or Pear, not by direct download.
  3. it's not on the packaging whitelist on Drupal.org, but I can request that it be added since the license doesn't conflict.

So how can I make this happen? Is there a pre-bundled-and-ready-to-use package somewhere that includes all dependencies, in which case I can just request that that be whitelisted for Drupal.org and use that? Or is installing Guzzle tricker than just including a bunch of files that can be placed in sites/all/libraries?

Any ideas?

2 Answers 2

1

I disabled composer system wide on my machine and create a make file and it works fine installing Drupal 7 core plus the following modules: composer, composer_autoload & guzzle.

This is the content of platform.make

$Id$

; API

api = 2

; Core

core = 7.x

; Drupal project.

projects[drupal][type] = core  
projects[drupal][version] = 7.x  
projects[drupal][download][type] = git  
projects[drupal][download][branch] = 7.x  

; Modules

projects[composer] = 1.x-dev  
projects[] = composer_autoload  
projects[] = guzzle
3
  • How/why did you come to the conclusion that composer_autoload is needed? Oct 21, 2013 at 20:21
  • Anyways, this doesn't seem to work for me. It downloads them all and you can install them, but if you go to /admin/help/guzzle which does a test Guzzle call, it says "Class not found" Oct 21, 2013 at 20:28
  • Specifically, it puts all 3 in sites/all/modules like "composer" is a regular module, and doesn't actually run any of the Composer magic. Oct 21, 2013 at 20:39
1

Use Composer Manager which would allow you to install PHP libraries managed via Composer and their dependencies on a per-project basis.

So (as per module's README.md):

If a module contains a composer.json file, running composer install in its root directory will download all requirements and dependencies to vendor/ directories with their own autoloaders.

The Guzzle challenge is explained in README.md:

To highlight the challenges, let's say module_a requires "guzzle/http": "3.7.*" and module_b requires "guzzle/service": ">=3.7.0". At the time of this post, running composer install in each module's directory will result in version 3.7.4 of guzzle/http being installed in module_a's vendor/ directory and version 3.8.1 of guzzle/service being installed in module_b's vendor/ directory.

Because guzzle/service depends on guzzle/http, you now have duplicate installs of guzzle/http. Furthermore, each installation uses different versions of the guzzle/http component (3.7.4 for module_a and 3.8.1 for module_b). If module_a's autoloader is registered first then you have a situation where version 3.8.1 of \Guzzle\Service\Client extends version 3.7.4 of \Guzzle\Http\Client.

So by using the Composer Manager's Solution, it finds all composer.json files in each enabled module's root directory and gracefully merge them into a consolidated composer.json file (which prevents code duplication and version mismatches).

For the use case above, Composer will resolve both guzzle/http and guzzle/service to version 3.7.4 which is a more consistent, reliable environment.


So to answer the question: yes, you can include that in a Drupal installation in sites/all/vendor, e.g.

  • sites/all/vendor/composer
  • sites/all/vendor/guzzlehttp

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.