0

I am getting this error:

Fatal error: Class 'http\Client' not found in /var/www/html/scripts/collections_getter_controller.php on line 46

The problem is the script "collections_getter_controler" is an include from two different scripts. When I exec the first one no error is prompted; however, when I exec the second one the error appears.

First script:

<?php
require "predis/autoload.php";
include "collections_getter_controller.php";
include "metadata_getter_controller.php";
include "bits_getter_controller.php";
include "invertedIndex.php";
Predis\Autoloader::register();

try {
    $redis = new Predis\Client();
.
.
.

The second script:

<?php
include "collections_getter_controller.php";
include "bits_getter_controller.php";

$itemIds = getCollectionitemIds('6');
.
.
.

As you can see in both cases the first include is "collections_getter_controller", so I can not identify what can be the problem because it's loaded in the first script but not the second.

Also, I should mention, I'm working on a Docker Image which is

FROM php:5.6.34-apache-jessie

EDIT

Following ceejayoz comment I'm adding the part of "collections_getter_controler" in which http\Client is used

<?php

$xml = simplexml_load_file('../scripts/getter_config.xml');

# Here goes more code not related to the question

function getJSONCollections($id_req, $i){
    set_time_limit(0);
    $client = new http\Client;
    $request = new http\Client\Request;
    switch ($i) {
        case '1':
            $request->setRequestUrl((string)$GLOBALS['xml']->request->request_url.'/collections/'.$id_req);
            break;
        case '2':
            $request->setRequestUrl((string)$GLOBALS['xml']->request->request_url.'/collections/'.$id_req.'/items');
            break;
        default:
            $request->setRequestUrl((string)$GLOBALS['xml']->request->request_url.'/collections/'.$id_req);
            break;
    }
    $request->setRequestMethod((string)$GLOBALS['xml']->request->request_method);
    $request->setHeaders(array(
      'postman-token' => (string)$GLOBALS['xml']->request->header_token,
      'cache-control' => (string)$GLOBALS['xml']->request->header_cache,
      'authorization' => (string)$GLOBALS['xml']->request->header_auth
    ));

    $client->enqueue($request)->send();
    $response = $client->getResponse();
    return $response->getBody();
Esteban Sierra
  • 61
  • 1
  • 10
  • Presumably, `getCollectionitemIds` uses the `http\Client` class somehow. Can you show us what that function does? – ceejayoz Apr 10 '18 at 15:37
  • @ceejayoz There is the update to the question – Esteban Sierra Apr 10 '18 at 15:43
  • Where does the `http\Client` class come from? Is it your code? A library you're loading? – ceejayoz Apr 10 '18 at 15:46
  • The problem there is that I was just given the Scripts and requested to build the Docker Image to run them. There is not any http\Client Code or Library mentioned by the author of the script – Esteban Sierra Apr 10 '18 at 15:49
  • It's really hard to say without the entire codebase. The `http\Client` stuff looks like an older version of Guzzle (http://docs.guzzlephp.org/en/stable/). These days, it'd be installed with Composer and you'd be using the Composer autoloader for everything, but this code may predate that approach. – ceejayoz Apr 10 '18 at 16:02
  • Thanks @ceejayoz. I'll contact the code author for more details and I'll take into account your comment – Esteban Sierra Apr 10 '18 at 16:08

0 Answers0