$ show clue/reactphp-stdio
clue/reactphp-stdio is a PHP library that provides async, event-driven console input & output (STDIN, STDOUT) for building truly interactive CLI applications. Built on top of ReactPHP, it implements a duplex stream that manages the complex interaction between asynchronous output and input redrawing, ensuring the user's input prompt and cursor position remain stable even when output occurs concurrently. The library handles UTF-8 input properly, provides features like customizable prompts, input echo control (including password masking), cursor positioning, command history, autocomplete/tab completion, custom key bindings, and bell signals. It takes care of proper TTY settings and restoration without requiring extensions, though it can utilize ext-mbstring for better performance and ext-readline for raw terminal mode when available.
The LLM identified 1 files worth highlighting for reuse:
Contains robust UTF-8 string handling utilities (strlen, substr, strwidth, strsplit) with graceful fallbacks to mbstring functions when available. These utilities solve the fundamental problem of handling Unicode strings in terminal applications where byte length ≠ character length ≠ display width, which is critical for correct cursor positioning and text rendering. Demonstrates non-obvious skill in implementing proper Unicode handling with fallbacks ensuring compatibility across PHP versions and environments, forming the foundation for all text manipulation in the library.