Running PhantomJS with PHP server side -


i'm trying run phantomjs using php on linux web server. run cron job i'm running through php script uploading via ftp server.

php script:

$cmd = '/usr/local/bin/phantomjs /home/accountname/public_html/myscript.js'; $result = exec($cmd); var_dump($result); 

(note have changed account name in path above "accountname" privacy correct in real script - , copied myriad of other php scripts work perfectly.)

myscript.js content:

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

the resulting output is:

string(0) "" 

i have tried number of examples phantomjs website never output - either on screen, in console or examples create screenshots png files never appear in right place - though specifying exact paths.

i did try returning phantomjs version , returned correct version:

$cmd = '/usr/local/bin/phantomjs --version'; $result = exec($cmd); var_dump($result); 

returned:

string(5) "1.9.2" 

i know "exec" not safe way of running things in php - i'm trying test phantomjs works started, , we'll adjust work safely.

any ideas? in advance.

try use:

$cmd = 'unset dyld_library_path ;'; $cmd.= ' /usr/local/bin/phantomjs'; //where isntalled phantomjs $cmd.= ' /var/www/rasterize.js'; //where script exec($cmd.' 2>&1', $output); print_r($output); 

this script tested on ubuntu 12.04 php 5.4.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -