This can lead to more predictable results -
For testing purposes, simply use:
exec("phantomjs phantom.js");
Make sure phantomjs are running in the same folder as the php executable script.
Second, lose the $ output variable. I tried something similar to what you tried, and it wonβt work - your phantom script will not return anything in its current state, and shell_exec is on the way to obsolescence for its unpredictable and unreliable nature. IMHO shell_exec is hacker and temporary at best.
Thirdly, CHMOD is your folder for "777" for testing. Or save the page rendering output to a folder with write permissions.
As for the returned usable data (read: it can be used for several simultaneous users, since this is a slow and blocking operation) from the PhantomJs script to your PHP script .... well ... here's the problem: ...
source share