alwex / php-casperjs

simple PHP wrapper for CasperJS
MIT License
182 stars 71 forks source link

Can not find CasperJS #60

Closed crouti closed 6 years ago

crouti commented 6 years ago

Hi,

I am using php-casperjs in a wordpress plugin. I installed as recommended with

npm install phantomjs
npm install casperjs

then

composer require phpcasperjs/phpcasperjs

i can initialize casper without error like this:

try {
    $casperJSExecutable = trailingslashit(realpath(dirname(__FILE__) . '/node_modules/casperjs/bin/casperjs'));
    self::getLogger()->trace("Casper path : " . $casperJSExecutable);
    $this->casper = new Casper($casperJSExecutable, '/tmp');
} catch (Exception $e) {
    self::getLogger()->error($e->getMessage());
}

but as soon as i run it, the error in the title of this post appears

try {
    $this->casper->run();
} catch (Exception $e) {
    self::getLogger()->error("####### ERROR #######");
    self::getLogger()->error($e->getMessage());
    return null;
}

Any idea ? Thanks a lot

crouti commented 6 years ago

Is there an other way i should use to pass to php-casperjs the path to casperjs executable, which is done here during Casper instanciation:

$casperJSExecutable = trailingslashit(realpath(dirname(__FILE__) . '/node_modules/casperjs/bin/casperjs'));
    self::getLogger()->trace("Casper path : " . $casperJSExecutable);
    $this->casper = new Casper($casperJSExecutable, '/tmp');

Is there a problem here ? Thanks

crouti commented 6 years ago

Ok, the path was not good, need to provide the parent directory, not the exe file:

$casperJSExecutable = trailingslashit(realpath(dirname(__FILE__) . '/node_modules/casperjs/bin/'));

stickypages commented 5 years ago

Thanks for this!