I am using PhantomJS 64 bit in my PHP application to dynamically capture an HTML page to send to the user via email.
phantomjs rasterize.js "http://..." /path_to_images/image.png
This method works fine when I run the above on the command line, but when the PHP script runs the command using exec , it fails without output and returns exit code 11.
If I switch it to use the phantomJS 32-bit binary, the command will succeed, but will not be able to load Google JSAPI on the page with the Reference Error: can't find variable google error. This is a problem because not all page content is loaded and recorded as an image. JSAPI is enabled using HTTPS. If I switch to HTTP, the reference error will disappear, but the resulting image will turn black.
I tested the command as the same user that php works like.
Summarizing:
command> phantomjs_64 rasterize.js "http://..." /path_to_images/image.png
Ok
exec('phantomjs_64 rasterize.js "http://..." /path_to_images/image.png');
No exit, exit code 11
command> phantomjs rasterize.js "http://..." /path_to_images/image.png exec('phantomjs rasterize.js "http://..." /path_to_images/image.png');
Incomplete exit
Does anyone know why, by default, the phantomJS rasterize.js script will fail when launched in PHP, or will there be a workaround for this?
php phantomjs lamp shared-hosting
Preston s
source share