I have completed the installation guide for PHP PhantomJS . When running a test script using PHP PhantomJS, I get an error message:
PHP Fatal error: Class 'JonnyW\PhantomJs\Client' not found in ...
I have not used Composer before, so I may have missed something. I run this from MAMP, so there may be some features related to those that are not mentioned in the documentation. If I open the test script in the browser, I get a blank screen. It is only from running php from Terminal that I get Fatal error .
The script line does not work:
$client = Client::getInstance();
Therefore, I assume that it does not load correctly from Composer. I can verify that both phantomjs and phantomloader are in /bin .
What steps should be taken to properly load the PHP PhantomJS script?
- update -
test.php (taken directly from PHP PhantomJS example)
use JonnyW\PhantomJs\Client; $client = Client::getInstance(); $request = $client->getMessageFactory()->createRequest(); $response = $client->getMessageFactory()->createResponse(); $request->setMethod('GET'); $request->setUrl('http://google.com'); $client->send($request, $response); if($response->getStatus() === 200) { echo $response->getContent(); }
source share