I have a casperJS script that returns JSON when run through the command line. I want to make the API preferably in PHP, which runs the script as on the command line (casperJS sample.js), and returns the JSON result.
I think you can use the php exec () function as shown below to do this
echo exec("/home/user/casperjs/bin/casperjs /full/path/to/your_script.js");
You can use the php-casperjs library, which is a simple wrapper for casperjs.
casperjs