A PHP internals discussion about a new alpha extension (php-terminal) that exposes native cross-platform terminal primitives for CLI applications. The extension addresses gaps in PHP's current userland capabilities, especially on Windows, covering TTY detection, terminal size reading, raw mode toggling, single-key input, and direct stdout/stderr writing. The motivation stems from Laravel Prompts being unable to run its interactive flow on Windows due to Unix-only terminal dependencies. Derick Rethans reviewed the API and suggested grouping all functions under a Terminal\Terminal class, using enums for backend types, stream names, and special key presses. The author responded by releasing v0.3.0 implementing these suggestions, replacing the procedural API with a class-based one using Terminal\Backend, Terminal\Stream, and Terminal\Key enums.

5m read timeFrom externals.io
Post cover image
517 Impressions