[RFC / Proposal] Built-in Native Terminal Primitives for TypePHP Standalone CLI Applications #83
prateekbhujel
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
TypePHP is a massive step forward for the PHP ecosystem, enabling ahead-of-time (AOT) compilation into standalone native executables (
--mode=bin). Standalone binaries are particularly compelling for command-line tools, utilities, background workers, and system daemons.However, modern CLI applications (interactive prompts, menus, password prompts, spinners, TUIs, terminal dimensions) fundamentally depend on low-level terminal primitives:
getSize()).NO_COLOR.Currently in standard PHP, CLI tools (such as Laravel Prompts or Symfony Console) resort to workarounds like shelling out to
sttyon POSIX ormode CONon Windows, or bundling external helper executables to read masked passwords. In a standalone AOT-compiled binary, spawning shell sub-processes breaks single-binary isolation, impacts startup latency, and fails in restricted environments.Potential Solution: Dependency-Free Native Terminal Primitives
We have built and tested a pure, dependency-free C extension for terminal primitives (
php-terminal):termioson Linux & macOS, and the Win32 Console API on Windows.ncurses.terminal.stub.php).Discussion & Questions for the Maintainers
We would love to get feedback from @rango and the community on how this could best fit into TypePHP:
mode: bin), or do you prefer keeping it as an optional TypePHP-compatible package / example inexamples/?tpcitself benefit from native terminal detection (e.g. dynamic responsive progress bars matching terminal width viagetSize(), or interactive project wizards)?Terminal\orTypePhp\Terminal\)?I am eager to contribute a PR with an implementation and examples if this direction aligns with TypePHP's roadmap!
All reactions