After some research surrounding this I can't seem to fix this issue. So for a project I made a simple module with some variables that simply has to make an OAuth1 call and return some data.

The provider of the website advised me to use :


So in my module I initialised another composer.json and required the package above. It gets correctly installed to the vendor map in my module. However whenever I call the new OAuth() or new OAuth1() it can't be found.

I've tried adding it while using the packagepath in the top of my module.php as well as my moduleVariable.php but to no avail. I was wondering if I'm doing something wrong? Or forgetting something? What's the best way to add composer libraries to your own custom module?

Best regards!

2 Answers 2


The easiest way around this is to include the required library in your main-project composer.json and let it handle it rather than your modules composer.json.

The alternative is to require your module properly in your main composer file as you do with plugins and install it via path which kinda breaks the idea of it

  • Alright but when I remove my composer data from my module itself, and install the plugin in my main folder I still can't access the required php plugin. It keeps returning tha same error. (class not found)
    – Stef Dg
    Commented Oct 23, 2018 at 11:28
  • Full error text: "Class 'modules\sha1hashingmodule\variables\OAuth1' not found"
    – Stef Dg
    Commented Oct 23, 2018 at 11:37
  • Because there is no such a class in the package Commented Oct 23, 2018 at 12:45
  • Indeed, seems it was a mistake on my end. I have to install it trough PECL.
    – Stef Dg
    Commented Oct 23, 2018 at 12:47
  • No you just need to install it via Composer and use the correct classes Commented Oct 23, 2018 at 12:48


Had to do a sudo pecl install oauth in order to get access to the right OAuth. Had to add the extension to my php.ini and restart my server.

public function apiCall($consumer_key, $consumer_secret, $token, $token_secret, $baseURL) {
    try {

        $oauth = new \OAuth($consumer_key, $consumer_secret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);


        $response_info = $oauth->getLastResponseInfo();
        return $oauth->getLastResponse();

    } catch(OAuthException $E) {

        echo "Exception caught!\n";
        echo "Response: ". $E->lastResponse . "\n";


And lastly had to execute the above function in order to get the data I asked for.

Your Answer

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

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