2

I made a library to access to the Taleo data ( https://github.com/Polzme/Taleo ). I tried to follow the best practice to do it. It's using composer ( http://getcomposer.org/ ) to resolve dependencies to Monolog and Guzzle.

Now, the big question is, how to use my library 'Taleo' in a Drupal module ?

I tried with xautoload ( http://drupal.org/project/xautoload ) and composer_autoload ( http://drupal.org/project/composer_autoload ) without success.

I also tried to include the file 'vendor/autoload.php', but it doesn't works (and it works well in the demo.php file: https://github.com/Polzme/Taleo/blob/master/demo.php)

Before including each file manually, I would like to know if there is a working solution available for Drupal 7.

Thanks!

4

It is indeed possible with xautoload.

Here is some explanation what initially went wrong: https://gist.github.com/4018045

As a general guide:

function hook_libraries_info() {
  return array(
    'Taleo' => array(
      'name' => 'Taleo PHP Library',
      'xautoload' => function($api) {
        // $api already knows the library path.
        // 'src' is relative to that.
        $api->namespaceRoot('Taleo', 'src');
      },
    ),
  );
}

The $api object is explained here: http://drupalcode.org/project/xautoload.git/blob/refs/heads/7.x-2.x:/lib/InjectedAPI/hookXautoload.php

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.