What is Phui?
Phui (pronounced like "phooey") is a PHP framework for building terminal user interfaces (TUIs) — interactive applications that run inside your terminal.
Why build a TUI?
TUIs fill a real production niche, especially in internal and developer tooling. They shine when:
- You want varied functionality at your fingertips without context-switching to a browser or app.
- You want that functionality to be explorable — one interface you can navigate, rather than a pile of flags and subcommands to memorise.
- You need it to work wherever a terminal works — over SSH, in a container, on a headless server.
But honestly? The best reason is that building a TUI is fun! A TUI is a novel way to interact with your side projects and personal tools, without the weight of the logistics and dependencies that come with the web stack.
Okay, but why build a TUI with Phui?
A terminal gives you almost nothing to build on: it's a grid of character cells, and the only real primitive is printing text at a coordinate. Everything an interactive app needs on top of that is your problem — working out what to repaint when state changes, parsing raw input bytes into keys and mouse events, reacting to resizes, managing the cursor, and restoring the terminal cleanly when you exit. Phui absorbs all of that:
- Declarative UI — describe what to render; Phui diffs and paints frames for you, redrawing only changed cells.
- Layout & styling — flexbox-like containers with padding, margin, sizing rules, and scrolling; colours, gradients, borders, theming, and much more.
- Reactive state — change your component's state and the UI updates itself; no manual redraw calls anywhere in your code.
- Rich input — every keystroke, mouse action, and system change is delivered to your app as a typed event.
- Terminal hygiene — the terminal is set up on start and restored cleanly on exit, however your app ends.
And you get all of this in modern, fluent PHP. Terminal UIs have mostly been the domain of other languages — PHP isn't exactly the first thing that springs to mind for a long-running interactive app — but modern PHP is well up to the job. Phui leans on fibers, and plays happily with anything else that does, so slow work can tick away in the background while the UI keeps rendering.
There's no new language to pick up, and nothing to install beyond a Composer package with no dependencies but PHP itself — Phui slots into your existing codebase and can lean directly on the models, services, and clients you already have.
Ready to build something? Head to Getting Started to install Phui and write your first app.