tcgetattr(STDIN_FILENO, FFI::addr($original_termios)); $termios = clone $original_termios; $termios->c_lflag &= ~(_ECHO | ICANON); // Turn on raw mode $ffi->tcsetattr(STDIN_FILENO, TCSAFLUSH, FFI::addr($termios)); } function disableRawMode(): void { global $ffi; global $original_termios; $ffi->tcsetattr(STDIN_FILENO, TCSAFLUSH, FFI::addr($original_termios)); } function read_stdin() { $handle = fopen('php://stdin', 'r'); $input = rtrim(fgets($handle, 128)); fclose($handle); return $input; }