I am trying to use PHP PhantomJS to load a page, but I get the error
Fatal error: Uncaught JonnyW\PhantomJs\Exception\ProcedureFailedException: Error when executing PhantomJs procedure - File does not exist or is not executable: bin/phantomjs in /Volumes/WWW ROOT/namechase/www/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php:138
Stack trace:
#0 /Volumes/WWW ROOT/namechase/www/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Client.php(162): JonnyW\PhantomJs\Procedure\Procedure->run(Object(JonnyW\PhantomJs\Http\Request), Object(JonnyW\PhantomJs\Http\Response))
#1 /Volumes/WWW ROOT/namechase/www/crawling.php(30): JonnyW\PhantomJs\Client->send(Object(JonnyW\PhantomJs\Http\Request), Object(JonnyW\PhantomJs\Http\Response))
#2 {main}
thrown in /Volumes/WWW ROOT/namechase/www/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php on line 138
This only happens on one of my test domains, and not the other.
The code I am running on both domains is identical, but doesn't work on one of the two test beds. Both are running on the same machine, just using different virtual hosts, but only one is returning the error.
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
echo '<pre>';
use JonnyW\PhantomJs\Client;
$client = Client::getInstance();
$delay = 5; // 5 seconds
$request = $client->getMessageFactory()->createRequest('https://google.com', 'GET');
$request->setDelay($delay);
/**
* @see JonnyW\PhantomJs\Http\Response
**/
$response = $client->getMessageFactory()->createResponse();
// Send the request
$client->send($request, $response);
if($response->getStatus() === 200) {
// Dump the requested page content
echo $response->getContent();
}
I have tried setting the path to phantomjs
in the composer.json
file using
"config": {
"bin-dir": "/usr/local/bin"
}
but this doesn't seem to make any difference