$ show thephpleague/climate
CLImate is a PHP library that provides a fluent, intuitive API for formatting and outputting text to the terminal. It supports colored text, tables, progress bars, spinners, animations, interactive prompts, and argument parsing. The library abstracts away platform-specific differences (Linux vs. Windows, ANSI vs. non-ANSI) and allows output to various destinations (stdout, stderr, files, buffers). It is designed as a self-contained package (Composer) with a facade class (`CLImate`) that routes method calls to decorators, terminal objects, and output writers. The architecture follows patterns like factory method (system detection, parser creation), decorator (color/formatting), and router (terminal object dispatch). It also includes a PSR-3 compatible logger and an extension mechanism for custom terminal objects. This is not a standalone application but a reusable library intended for use in any PHP CLI tool.
The LLM identified 3 files worth highlighting for reuse:
Provides a clean, self-contained argument definition and parsing system. Supports short/long options, defaults, required arguments, value aliases, and summary generation. It imports only internal Argument, Filter, and Summary classes, but the core parsing logic is isolated enough to be extracted into a standalone library for any CLI tool.
Implements the factory pattern to detect the operating system and return the appropriate System implementation (Linux or Windows). Decouples platform-specific terminal operations (dimensions, ANSI support) from the rest of the library. This class is minimal and could be reused independently to provide terminal capabilities from a single factory call.
A simple output buffer that implements WriterInterface. It stores all written output in memory and provides a method to retrieve it. Useful for testing, deferred output, or capturing terminal output without side effects. The implementation is straightforward, has zero internal dependencies (only the interface), and can be extracted and reused in any project needing an in-memory writer.