php-school/terminal
php-school/terminal is a PHP library for building interactive terminal apps. It provides input/output helpers, ANSI styling, cursor control, and terminal state management, making it easy to create rich CLI UIs with prompts, menus, and formatted output.
Start by installing the package via Composer (composer require php-school/terminal). Its primary use case is detecting terminal environment properties to conditionally format output. The first thing you’ll reach for is Terminal::isatty() to verify whether output goes to an actual terminal (vs. a pipe or file), and Terminal::getSize() to get width/height for responsive layout. Look at php-school/terminal’s TerminalInterface—it defines a clean, minimal API with no heavy dependencies. Since the last release was in 2019, assume it’s stable but lightly maintained; ideal for foundational terminal introspection where full frameworks (like Symfony Console) would be overkill.
isatty() to enable colors only when supported (if ($terminal->isatty(STDOUT)) { $output->write('<fg=yellow>…</>'); }), avoiding ANSI codes breaking log files or CI outputs.getSize() with width()/height() to adjust table columns or progress bar width ($width = $terminal->getSize()->getWidth(); $bar->setMaxWidth($width - 10)).getCapabilities()—e.g., disable interactive prompts if supportsInteractive() returns false (useful for CI, cron jobs, or non-TTY CI runners).php mytool.php | grep foo to work without garbled output.windows-latest).isatty(STDIN) is critical for tools that behave differently in pipelines (php mytool.php | grep bar). Never assume TTY → always check stdin/output separately.Terminal::mock() or a test-double that returns fixed dimensions/capabilities—don’t rely on actual terminal environment.php-school/terminal as the detection layer, but let a more active library (like symfony/console) handle rendering.How can I help you explore Laravel packages today?