azjezz/psl
PSL is a modern, well-typed standard library for PHP 8.4+, inspired by HHVM’s HSL. It offers safer, predictable APIs for async, collections, networking, I/O, crypto, terminal UI, and robust data validation—replacing brittle built-ins with consistent alternatives.
The Terminal component provides a full-featured TUI (Terminal User Interface) framework built on top of the Ansi and Async components.
It handles the event loop, raw mode, input parsing, diff-based rendering, and provides a library of composable widgets for building interactive terminal applications.
@example('terminal/terminal-quick-start.php')
The framework follows an immediate-mode rendering model:
For local terminal applications using STDIN/STDOUT:
@example('terminal/terminal-create.php')
This automatically handles raw mode, terminal size detection, SIGWINCH/SIGINT signal handling, and in-band resize notifications.
For remote scenarios (e.g. SSH servers) or testing, where you provide your own I/O handles:
@example('terminal/terminal-custom-io.php')
In this mode, raw mode is not managed by the application -- the caller is responsible for it. Signal handlers are not registered, and Ctrl+C is handled via the input stream parser. Use $app->dispatch(new Event\Resize($cols, $rows)) to inject resize events.
Register handlers for specific event types. Multiple handlers per event type are supported:
@example('terminal/terminal-events.php')
Periodic callbacks can be registered for tasks like polling or animation:
@example('terminal/terminal-interval.php')
The layout system splits rectangular areas into sub-regions using constraints:
@example('terminal/terminal-layout.php')
All widgets implement WidgetInterface with a single method: render(Rect $area, Buffer $buffer): void. They use a builder pattern for configuration.
Multi-line text with wrapping, scrolling, and alignment:
@example('terminal/terminal-paragraph.php')
A container that draws a border and optional title around an inner widget:
@example('terminal/terminal-block.php')
Border styles: Border::rounded(), Border::plain(), Border::double(), Border::thick().
Columnar data with headers, scrolling, and row highlighting:
@example('terminal/terminal-table.php')
A selectable list of items with scrolling and highlight:
@example('terminal/terminal-menu.php')
@example('terminal/terminal-text-primitives.php')
The Buffer is a 2D grid of Cell objects. Widgets write to it, and flush() performs diff-based rendering:
@example('terminal/terminal-buffer.php')
See src/Psl/Terminal/ for the full API.
How can I help you explore Laravel packages today?