I am trying to integrate Prompt Cloud API with magento. For it the basic requirement is to install Unirest library. I am trying to install using composer:

composer require mashape/unirest-php

And then trying to call it in head.phtml as:

$headers = array('Accept' => 'application/json');
$query = array('foo' => 'hello', 'bar' => 'world');

$response = Unirest\Request::post('http://mockbin.com/request', $headers, $query);

But it is throwing error: 500 Internal server error. When I have checked system.log file, it contains following errors:

2017-06-27T08:42:29+00:00 ERR (3): Warning: include(Unirest\Request.php): failed to open stream: No such file or directory in /lib/Varien/Autoload.php on line 94

1 Answer 1


You will need to add the composer autoloader (vendor/autoload.php) and register it before the Magento autoloader. That's important because the Magento autoloader will try to include the file where it expects the class to be which throws an error if that file does not exist. So later autoloaders do not have a chance at all.

There are some open source extensions that can do that for you, I can recommend https://github.com/magento-hackathon/Magento-PSR-0-Autoloader

Configuration as per README:

Magento Composer Autoloader

You can also use this Extension to add the composer Autoloader.

You need to configure the Path to your Vendor directory in your <global/>-node of local.xml:

  • Thanks for answering. I have installed that extension by copying app directory to magento and in admin this extension is coming as enabled. Do I need to do something else because the problem is still the same? Commented Jun 28, 2017 at 8:48
  • 1
    @TriyugiNarayanMani yes, it's explained in the readme section "Magento Composer Autoloader" Commented Jun 28, 2017 at 8:49
  • But I don't have vendor directory. And it also say to disable default autoloader. Is it necessary? Commented Jun 28, 2017 at 8:51
  • 1
    @TriyugiNarayanMani that's impossible. If you successfully ran composer require, it created a vendor directory. Did you run that in the right directory? Commented Jun 28, 2017 at 8:52

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.