phpphp-phantomjs

Can't use PHP-Phantomjs


I'm trying to use PhantomJS, this is my code :

<?php
    require '../../../../vendor/autoload.php';

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

    var_dump($response);
?>

But it's giving me this error :

Fatal error: Uncaught exception 'JonnyW\PhantomJs\Exception\ProcedureFailedException' with message 'Error when executing PhantomJs procedure "default" - File does not exist or is not executable: bin/phantomjs' in /var/www/html/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php:132 Stack trace: #0 /var/www/html/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Client.php(170): JonnyW\PhantomJs\Procedure\Procedure->run(Object(JonnyW\PhantomJs\Client), Object(JonnyW\PhantomJs\Message\Request), Object(JonnyW\PhantomJs\Message\Response)) #1 /var/www/html/vendor/jonnyw/php-phantomjs/examples/basic-request.php(15): JonnyW\PhantomJs\Client->send(Object(JonnyW\PhantomJs\Message\Request), Object(JonnyW\PhantomJs\Message\Response)) #2 {main} thrown in /var/www/html/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php on line 132

So it's crashing at this line :

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

I tryed to chmod 777 all the \vendor directory and childrens but don't change anything, have you got a idea ?


Solution

  • Ok, I just have to add the link to the bin directory, which is in my project's root.