0

I'm on a Windows platform, I have the phantomjs executable on app/webroot/phantomjs and a js in the same folder. When I do on php:

$response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js');

nothing happens. This is the content of the js:

console.log('Hello, world!');
phantom.exit();

I use absolute paths because this needs to be executed on a webpage online.

EDIT 1:

when using

$response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js 2>&1', $s, $o);

        echo $response;
        echo "<pre>";
        print_r($s);
        echo "</pre>";

        echo "<pre>";
        print_r($o);
        echo "</pre>";

I get

Array
(
)

1

EDIT 2:

this works fine:

echo exec("whoami");

EDIT 3: This does nothing:

$response = exec($this->webroot . 'app/webroot/phantomjs/phantomjs getweb.js 2>&1', $s, $o);
Mariano
  • 19
  • 6
  • Please enable error reporting and try to pipe sterr to stout: http://stackoverflow.com/q/12199353 – Artjom B. Sep 11 '14 at 14:52
  • Error reporting enabled, no results. Same with 2>&1 – Mariano Sep 11 '14 at 15:08
  • You should check that `$this->webroot` contains only forward slashes and ends with one. Check that the complete path is the correct path (`echo` it). Does the getweb script also need a specific path? – Artjom B. Sep 11 '14 at 15:16
  • path is correct and the getweb is in the exact same folder. – Mariano Sep 11 '14 at 17:28

1 Answers1

0

I was facing the same problem.. The thing is phantomjs requires complete path for all. Here is the solution I came up with:

$getout = exec('D:\\xampp\\htdocs\\phantomjsdir\\phantomjs.exe D:\\xampp\\htdocs\\rasterisejsdir\\rasterize.js http://localhost/pagetobecaptured/test D:\\xampp\\htdocs\\outputfiledir\\test2.jpg "1800px*840px"',$o,$e);
alegostack
  • 11
  • 2