This repository contains a bleeding-edge example project demonstrating the capabilities of the experimental symfony/tui component.
The symfony/tui component shifts PHP CLI development from an immediate mode (manually redrawing lines) to a retained mode architecture. It is built on top of PHP Fibers and the Revolt event loop, enabling a fully concurrent, non-blocking terminal UI.
- PHP 8.4+ (Required for Fibers and modern language features)
- Composer
Because symfony/tui has not yet been merged into the Symfony mainline repository, this project installs it directly from Fabien Potencier's experimental tui branch.
-
Clone the repository:
git clone https://github.com/mattleads/TuiComponent.git cd TuiComponent -
Install dependencies:
composer install
(Note: This project is pre-configured to clone the experimental Symfony branch into
vendor-src/and map it as a local path repository).
A simple, reactive list widget demonstrating state changes and event listeners.
php bin/console app:server-dashboardFeatures Demonstrated:
SelectListWidgetinitialization and configuration.- Listening to
SelectEventto update aTextWidgetheader reactively. - Using
PaddingandBorderobjects in theStyleSheet. - Handling
CancelEvent(pressingEscorCtrl+C) to exit the TUI gracefully.
A fully-featured demo simulating a tabbed interface (using a sidebar) to showcase every available widget in the component.
php bin/console app:widgets-demoFeatures Demonstrated:
- Simulated vertical tabs using a
SelectListWidgetbound to aContainerWidget'sSelectionChangeEvent. - Custom
TABandShift+TABkeybindings for navigating between focusable widgets (overriding the defaultF6). - Dynamic styling based on
FocusEvent(e.g., highlighting the active window pane cyan).
- TextWidget & FIGlet: Demonstrates rendering standard text and large ASCII art banners using bundled FIGlet fonts (e.g.,
font: 'slant'). - InputWidget: A single-line text field. Includes custom logic to hide/restore placeholder text on focus/blur.
- EditorWidget: A fully functional multi-line text editor with word wrap, kill-ring, and scrolling.
- SettingsListWidget: A preference panel allowing users to cycle through predefined values (e.g., Theme: Dark/Light).
- MarkdownWidget: Renders CommonMark markdown with full syntax highlighting (requires
league/commonmarkandtempest/highlight). - Loaders & ProgressBarWidget: Demonstrates background operations running concurrently via the Revolt
EventLoop. Includes custom styling for the progress bar to differentiate filled/empty states.