I am trying to load a class in order for a PHP script that I wrote, with help of the classes' documentation, to work.
Since my server is running PHP 5.3, the documentation recommended loading the class like this:
spl_autoload_register(function($class){
if (file_exists('/webgit/webroot/home/myUsername/www/elastica/lib/' . $class . '.php')) {
echo " found \n ";
require_once('/webgit/webroot/home/myUsername/www/elastica/lib/' . $class . '.php');
}
else {
echo " not found! ";
}
});
The only things that are different are that I included echo's in the suite of the if and else. Also myUsername is actually my username in the file-system path on the server.
Then, it ( the documentation ) suggests that I make a new instance of the class like so:
$elasticaClient = new \Elastica\Client();
However, I am getting an error that the class is not found. Here is exactly what is printed including the error and the suite of my if-else:
not found! Fatal error: Class 'Elastica\Client' not found in /webgit/webroot/home/myUsername/www/elastica/index.php on line 17
line 17 is the line where I try to make an instance of the class.
now, index.php is where the above code is and it is located, on my server, in /webgit/webroot/home/myUsername/www/elastica/
and all the class files are in /webgit/webroot/home/myUsername/www/elastica/lib/
so, I don't understand why it is not able to find / load the class.
I would greatly appreciate any help in solving this!