I'm using PhantomJS 64 bit in my PHP application to dynamically capture an HTML page to be emailed to the user.
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 with no output and returns exit code 11.
If I switch it to use the 32 bit phantomJS binary, the command succeeds but fails to load the google JSAPI on the page since with error Reference Error: can't find variable google
. This is a problem because not all of the page content is loaded and captured as an image. The JSAPI is included using HTTPS. If I switch to HTTP, the reference error is gone but the rendered image comes out all black.
I tested the command as the same user that php is running as.
To sum it up:
command> phantomjs_64 rasterize.js "http://..." /path_to_images/image.png
OK
exec('phantomjs_64 rasterize.js "http://..." /path_to_images/image.png');
No Output, Exit Code 11
command> phantomjs rasterize.js "http://..." /path_to_images/image.png
exec('phantomjs rasterize.js "http://..." /path_to_images/image.png');
Incomplete Output
Does anyone know why the default phantomJS rasterize.js script would fail when running on PHP or have a workaround for this?