jonnnnyw / php-phantomjs

Execute PhantomJS commands through PHP
MIT License
1.44k stars 431 forks source link

File does not exist or is not executable: #189

Open algobasket opened 7 years ago

algobasket commented 7 years ago

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

mohannadjaalouk commented 7 years ago

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

algobasket commented 7 years ago

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

c9s commented 6 years ago

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

contacthe commented 6 years ago

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

ysmnikhil commented 6 years ago

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

discountsqatar commented 2 years ago

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

PLQin commented 2 years ago

composer.json

{
    "name": "qing/server",
    "authors": [
        {
            "name": "Raymond",
            "email": "773561801@qq.com"
        }
    ],
    "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);