3

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();

2 Answers2

1

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.

Brian
  • 8,418
  • 2
  • 25
  • 32
0

Problem was about executable downloaded by composer, so following issue #86 I put this on my code:

$client->getEngine()->setPath('/usr/bin/phantomjs');

So now I'm using default binaries and works great.

Guille Acosta
  • 2,051
  • 23
  • 35