Download the PHP package tivins/tui without Composer
On this page you can find all versions of the php package tivins/tui. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tui
tivins/tui
Small PHP helpers for terminal user interfaces: cursor and screen control, Unicode bordered frames, side-by-side layout of multiline blocks, text progress bars, ANSI colors (16-color and 256-color foregrounds), a lightweight ASCII banner renderer, ANSI-aware string utilities, and a spinner with optional rotating grayscale on messages.
Requires PHP 8.1+ (typed enum). The mbstring extension is recommended for correct Unicode handling in banners and width calculations.
Install
There are no Composer runtime dependencies.
Highlights
| Area | Classes | What they do |
|---|---|---|
| Screen & cursor | Terminal |
Clear/move cursor, CPR, eraseLine, alternate screen, screenSize(), carriageReturn(), lineOverwritePrefix() (réécrire une ligne), cursorPreviousLine() (CPL, colonne 1). |
| Boxes | Frame |
Multiline bordered panels: presets single, double, rounded, heavy, optional titles, padding, independent border/content/title colors, colored content with correct alignment. |
| Layout | Layout |
horizontal(array $blocks, int $gap = 1) — place blocks side by side; each row is padded using Ansi::displayWidth so borders stay aligned. |
| Progress | ProgressBar |
render($percent, $width, ...) — Unicode-filled bar (█ / ░) without a spinner; complements Throbber’s {bar} placeholder. |
| Banners | AsciiText |
Three-line glyphs (Future Smooth subset) via AsciiText::get() and AsciiText::toString(). |
| Colors | TermColor |
TermColor::*->fmt(string) wraps text in SGR sequences. |
| ANSI & 256-color | Ansi |
stripSgr(), displayWidth(), fmtForeground256(int $code, string) for \e[38;5;nm foregrounds (e.g. grayscale 232–255). |
| Text effect | RotatingColors |
Shifting palette along a string: render($text, $offset, $palette); default grayscale uses smooth 256-color steps; palette entries may be TermColor or 256-color indices (int). |
| stdin | Console |
stdinIsTty() and readLine() for interactive pauses without mixing stdin with terminal inquiries. |
| Activity | Throbber |
Spinner (styles: braille, pipe, dots, line), template placeholders including {message}, {rotating_message} (grayscale wave; offset advances every tick() via internal rotatingColorOffset, independent of spinner wrap), {bar}, percent, elapsed, registerStyle(), barWidth(). |
Quick examples
Rotating colors
RotatingColors::render() applies a repeating palette along each UTF-8 character. The offset usually increases by one per animation frame. With Throbber, use {rotating_message} so the wave stays smooth when the spinner loops (the library uses a monotonic color offset, not the spinner frame index).
Framed panel
Use render() explicitly when you need a string inside another expression:
Side-by-side blocks and progress bar
Terminal size and fullscreen demo
ASCII banner
Only characters listed in AsciiText::CHARSET have glyphs (others render as blanks). Typical flow:
Runnable demos
From the repository root:
| Command | Description |
|---|---|
php examples/showcase.php |
Full-screen demo (alternate buffer, banners, framed panels). Waits for Enter when stdin is a TTY. |
php examples/fullscreen_demo.php |
Full-screen animated dashboard: Layout::horizontal, nested Frames, Throbber, RotatingColors, ProgressBar; cursorHome refresh; Enter when stdin is a TTY; short loop if not. |
php examples/frame.php |
Frame variants and edge cases. |
php examples/ascii_text.php |
Banner sample. |
php examples/throbber.php |
Throbber : défilement, une ligne puis deux lignes mises à jour en place (\r/\e[2K, \e[1A). |
php examples/rotating_colors.php |
RotatingColors and {rotating_message} : static output and a short live demo. |
Tests
Scripts under tests/ are plain PHP assertions (no PHPUnit):
Tooling
The glyph map for AsciiText is generated from tools/Future_Smooth.flf:
See CHANGELOG.md for release notes.
License
MIT.