phpphantomjsphp-phantomjs

PHP PhantomJS doesn't work on web server


Have the next problem: installed php phantomjs on MAMP. Made all using instructions from here: enter link description here

Everything is ok... Then i copied all my site files to my web hosting site folder and nothing worked. Made a var_dump of response and saw that:

object(JonnyW\PhantomJs\Http\Response)#156 (8) { ["headers"]=> NULL ["status"]=> NULL ["content"]=> NULL ["contentType"]=> NULL ["url"]=> NULL ["redirectURL"]=> NULL ["time"]=> NULL ["console"]=> NULL }

Why it doesn't work, why all is NULL? My code is:

require __DIR__ . '/vendor/autoload.php';

use JonnyW\PhantomJs\Client;

$client = Client::getInstance();

$request = $client->getMessageFactory()->createRequest('http://jonnyw.me', 'GET');

$response = $client->getMessageFactory()->createResponse();

var_dump($response);

$client->send($request, $response);


echo $response->getContent();

Solution

  • The most likley things is if it's shared hosting, they will more than probably not allow you to execute arbitrary executables... i.e. the executable in ~/bin/phantomjs

    To execute non-standard i.e. user installed stuff, you'll need a VPS or Dedicated server.