I have a script that's already finished & QA'd & on the prod servers. I don't want to change it. But I do want to test it locally with some benchmarking stuff.
This script does not run in "web space". it doesn't use $_GET or $_POST or anything arriving from HTTP. This is a script that handles certain internal processes on the server.
Where in a typical web app I'd do this:
$source = $_POST['source'];
This script does this:
// read from stdin
$fd = fopen("php://stdin", "r");
$source = "";
while (!feof($fd)) {
$source .= fread($fd, 1024);
}
fclose($fd);
So now my question is: how do I trigger this script, and pass it input? I'd like to write a separate unit test that sends input to this script and then shows me the output.
Maybe I can go to the Linux CLI and do "> php process.php", but then how does the "stdin" get in there?