From f0db354504c017640895c3173adfec2107b7731d Mon Sep 17 00:00:00 2001 From: stephenahiggins Date: Tue, 20 Feb 2018 20:55:31 +0000 Subject: [PATCH] Add path to phantomJS PHP unable to find PhantomJS when run on OSX. Implemented the PHANTOMJS_EXECUTABLE property to compensate for this. --- src/Casper.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Casper.php b/src/Casper.php index e5fec51..7cb1725 100644 --- a/src/Casper.php +++ b/src/Casper.php @@ -31,12 +31,13 @@ class Casper private $loadTime = ''; private $tempDir = '/tmp'; private $path2casper = '/usr/local/bin/'; //path to CasperJS + private $path2phantom = '/usr/local/bin/phantomjs'; // path to PhantomJS private $headers = []; private $status; private $statusText = ''; private $cookies = []; - public function __construct($path2casper = null, $tempDir = null) + public function __construct($path2casper = null, $tempDir = null, $path2phantom = null) { if ($path2casper) { $this->path2casper = $path2casper; @@ -44,6 +45,9 @@ public function __construct($path2casper = null, $tempDir = null) if ($tempDir) { $this->tempDir = $tempDir; } + if ($path2phantom) { + $this->path2phantom = $path2phantom; + } } /** @@ -601,8 +605,8 @@ public function run() foreach ($this->options as $option => $value) { $options .= ' --' . $option . '=' . $value; } + exec('PHANTOMJS_EXECUTABLE='.$this->path2phantom .' '. $this->path2casper . 'casperjs ' . $filename . $options, $output); - exec($this->path2casper . 'casperjs ' . $filename . $options, $output); if (empty($output)) { throw new \Exception('Can not find CasperJS.'); }