mini\CLI\ReadlineManager
class
Documentation
Wrapper around PHP's readline callback interface with proper signal handling
Provides a clean way to handle Ctrl+C:
- Returns '' if cancelled with content in buffer (user wants to clear line)
- Returns null if cancelled with empty buffer (user wants to exit)
$rl = new ReadlineManager('sql> ');
pcntl_signal(SIGINT, fn() => $rl->cancel());
pcntl_async_signals(true);
while (($line = $rl->prompt()) !== null) {
if ($line === '') continue; // Ctrl+C with content, or empty enter
$rl->addHistory($line);
processLine($line);
}
Properties (6)
private
string $prompt
private
?
string $input
private
bool $prompting
private
bool $installed
private
array $history
private
?
Closure $completionFunction
Methods (14)
Documentation missing
Documentation missing
Set the default prompt
Add entry to history
Clear all history
Get current history entries
Load history from array
Set completion function
Prompt for input
Cancel current prompt (call from signal handler)
Check if currently prompting
Get current line buffer content
Documentation missing
Documentation missing