php-phantomjs icon indicating copy to clipboard operation
php-phantomjs copied to clipboard

File does not exist or is not executable:

Open algobasket opened this issue 8 years ago • 7 comments

PLEASE RESOLVE THIS ISSUE Fatal error: Uncaught exception 'JonnyW\PhantomJs\Exception\InvalidExecutableException' with message 'File does not exist or is not executable: E:\phantomjs\bin' in E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Engine.php:245 Stack trace: #0 E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Engine.php(109): JonnyW\PhantomJs\Engine->validateExecutable('E:\phantomjs\bi...') #1 E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\scrap.php(11): JonnyW\PhantomJs\Engine->setPath('E:\phantomjs\bi...') #2 {main} thrown in E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Engine.php on line 245

image image image

algobasket avatar Jun 16 '17 13:06 algobasket

I have exactly the Same issue, still looking for a solution

mohannadjaalouk avatar Jun 20 '17 09:06 mohannadjaalouk

@mohannadjaalouk its better to use python with selenium and phantom as browser

algobasket avatar Jun 20 '17 10:06 algobasket

Please see PR #195

or use my fork repo, I've improved the path lookup here:

https://github.com/c9s/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Engine.php#L68

c9s avatar Jul 24 '17 09:07 c9s

I used this $client->getEngine()->setPath('bin\\phantomjs.exe'); for the path double \ after bin

contacthe avatar Sep 07 '17 23:09 contacthe

You are missing file name in your setPath() function, it should be setPath('bin' . D_S . 'phantomjs.exe') ;

ysmnikhil avatar Mar 12 '18 13:03 ysmnikhil

@contacthe you way worked, but the problem is ... all error were gone but no response ... blank page.

discountsqatar avatar Aug 13 '21 06:08 discountsqatar

composer.json

{
    "name": "qing/server",
    "authors": [
        {
            "name": "Raymond",
            "email": "[email protected]"
        }
    ],
    "require": {
        "php": ">=7.3",
        "jonnyw/php-phantomjs": ">=4.1",
        "jakoch/phantomjs-installer": "2.1.1-p08"
    },
    "scripts": {
        "post-install-cmd": [
            "PhantomInstaller\\Installer::installPhantomJS"
        ],
        "post-update-cmd": [
            "PhantomInstaller\\Installer::installPhantomJS"
        ]
    },
    "config": {
        "bin-dir": "bin"
    }
}

test.php

<?php

require 'vendor/autoload.php';

use JonnyW\PhantomJs\Client;

$client = Client::getInstance();

// https://phantomjs.org/download.html
// https://github.com/jonnnnyw/php-phantomjs/issues/142
$client->getEngine()->setPath(dirname(__FILE__).'/bin/phantomjs/bin/phantomjs.exe');

$width  = 800;
$height = 600;
$top    = 0;
$left   = 0;

/** 
 * @see JonnyW\PhantomJs\Http\CaptureRequest
 **/
$request = $client->getMessageFactory()->createCaptureRequest('https://www.runoob.com', 'GET');
$request->setOutputFile('./capture/file.jpg');
$request->setViewportSize($width, $height);
$request->setCaptureDimensions($width, $height, $top, $left);

/** 
 * @see JonnyW\PhantomJs\Http\Response 
 **/
$response = $client->getMessageFactory()->createResponse();

// Send the request
$client->send($request, $response);

PLQin avatar Aug 14 '21 06:08 PLQin