I trouble shooted all the way through the code and finally came to the conclusion that stdout was the culprit.
After juggling around the code, I can get it to work if I don't fclose stdout. It seems as though you cannot close stdout if you are gonna echo more text to screen? Is that what it is??
$out = fopen("php://stdout", "w");
$in = fopen("php://stdin", "r");
fwrite($out, "Which project should I launch? [blank = $defaultExtension]: ");
$ProjectName = trim(fgets($in));
//# This Logger will print to screen just fine
Logger::log(__CLASS__, "Testing: $ProjectName / ".$list[(int)$ProjectName]);
fclose($out);
//fclose($in);
//# If I put the logger here, however, the CLI will quit. It is a simple echoing class, outlined below.
//Logger::log(__CLASS__, "Testing: $ProjectName / ".$list[(int)$ProjectName]);
$tst = new $list[(int)$ProjectName]();
Logger.php
<?php
Class Logger {
static public function log($class, $message, $die=false) {
if($die) {
print("# $class (FATAL): $message\n");
while(true){};
exit();
}
print("# $class\t: $message\n");
}
}
?>
See, nothing fancy.
I'm happy to have found the cause of my original problem, but now I'm faced with another problem. It takes a few seconds to close the CLI on my own now. It used to be instant. I assume because the CLI is trying to close STDOUT?
Is there a way past this?