Tiny, easy-to-remember ANSI escape helper for building terminal UIs in PHP. Chainable API for styles/colors/cursor control, with a few handy components and utilities.
Works on any terminal that supports ANSI escapes (most modern terminals on macOS/Linux and Windows Terminal/ConEmu on Windows 10+).
Let's keep simple things simple. 😌
You don't need a whole framework to build a simple CLI app.
Zero dependencies, PSR-12 with strict types, and a beautiful chainable API. Perfect for small CLI tools, deployment scripts, or any terminal-based app where you need style without the weight.
- Standard 8/16 colors, 256-color palette, and truecolor (RGB, 24-bit)
- Bold, dim, italic, underline, inverse, hidden, strike-through styles
- Easy reset and chaining
- Table - Beautiful tables with borders and alignment
- Banner - Eye-catching banners for messages
- Progressbar - Progress tracking with customizable styles
- Spinner - Animated spinners for loading states
- Choice - Interactive selection prompts
- Panel - Flexible container layouts (vertical/horizontal) with borders and dividers
- PanelBlock - Individual content blocks that can be nested or standalone
- Input helpers - Line, multiline, and confirm prompts
- Keypress detection - Listen for arrow keys, ENTER, ESC, TAB, modifiers, and more
- Move cursor to any position
- Save/restore cursor state
- Show/hide cursor
- Alternate screen buffer support
- ANSI-aware string length and stripping
- Memory writer for testing
- Tab title and bell helpers
php examples/showcase.phpcomposer require ajaxray/ansikit<?php
require __DIR__ . '/vendor/autoload.php';
use Ajaxray\AnsiKit\AnsiTerminal;
use Ajaxray\AnsiKit\Components\{Table, Banner, Progressbar, Choice};
$t = new AnsiTerminal();
$t->clearScreen()->cursorHome();
$t->writeStyled("Hello PHP Ninja!\n", [AnsiTerminal::TEXT_BOLD, AnsiTerminal::FG_GREEN]);
$t->fg256(202)->bg256(235)->write("256-colors")->reset()->newline();
$t->fgRGB(255,165,0)->write("Truecolor (RGB)")->reset()->newline();
$table = new Table();
$table->setHeaders('Name','Age', 'Adult?')
->addRow('Anis','41', '✅')
->addRow('Fatima', '2.5', '❌')
->render();
$banner = new Banner();
$banner->render('Deploy Complete', ['Everything shipped!']);
$bar = new Progressbar();
$bar->renderLine(75, 100, 'Loading files...');
$choice = new Choice();
$selected = $choice->prompt('Choose deployment target:', ['Production', 'Staging', 'Development']);
$t->writeStyled("Selected: {$selected}\n", [AnsiTerminal::FG_GREEN]);- AnsiTerminal - Styles, colors, cursor control
- Table - Data tables with borders
- Banner - Message banners
- Progressbar - Progress tracking
- Spinner - Loading animations
- Choice - Interactive selection
- Panel - Container layouts with borders and dividers
- PanelBlock - Nested or standalone content blocks
- Input - User input helpers
- Keypress - Keyboard event handling
- Str - ANSI-aware string utilities
- Util - Terminal helpers
php examples/showcase.php # All components demo
php examples/progress.php # Animated status + progress bar
php examples/input.php # Interactive input demo
php examples/choice.php # Interactive choice component demo
php examples/choice-menu.php # Interactive menu system
php examples/keypress.php # Interactive key handling demo
php examples/keypress-advanced.php # Advanced key sequences
php examples/util.php # Tab title + bell helpers
php examples/panel.php # Panel and PanelBlock demo
php examples/nested_panel.php # Nested Panel and PanelBlock demo- PHP: >= 8.2
- Terminals: macOS/Linux native, Windows 10+ with Windows Terminal/ConEmu
- Fonts: Monospaced fonts recommended for best alignment
On Windows, ensure VT processing is enabled for ANSI sequences.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License — see LICENSE
Made with ❤️ for terminal builders. If you ship something with AnsiKit, I'd love to hear about it!

