wujunze/php-cli-color
wujunze/php-cli-color is a lightweight PHP library for adding ANSI colors and styles to command-line output. It supports foreground and background colors, 256-color terminals, and simple chained methods to make CLI scripts, logs, and console tools easier to read.
Architecture fit
wujunze/php-cli-color is a thin ANSI escape-code wrapper for terminal output. It has no framework coupling, no service provider, no config, and no facade — it is a set of static helpers that return decorated strings.app/Console/Commands, seeder output, or standalone scripts. It should never appear in domain, HTTP, or queue code.<info>, <comment>, <error>, <fg=green;options=bold> tags via OutputFormatter, plus $this->line(), $this->info(), $this->error(), and Table/ProgressBar styling. For a Laravel-native team, this package is largely redundant.Integration feasibility
composer require wujunze/php-cli-color, then call the static helpers inside a command. Effort is measured in minutes, not sprints.NO_COLOR convention.Technical risk
php floor, which may block or warn on PHP 8.2/8.3 installs and will interact badly with composer audit policies.Artisan::call() captured output. Laravel's own formatter already handles --no-ansi / non-decorated output correctly.cmd.exe and some CI runners without a modern terminal emulator.Key questions
composer.json PHP constraint? Can we install on our current PHP runtime without --ignore-platform-reqs?NO_COLOR, --no-ansi, or stream_isatty()? If not, who owns the guard logic in our code?OutputFormatterStyle that justifies the dependency?Stack fit
Migration path
ConsoleStyle helper in app/Support/Console/. No direct CliColor:: calls outside that class. This makes the eventual swap to OutputFormatter or a maintained alternative a one-file change.composer.json cannot resolve on PHP 8.2+, either fork to an internal namespace with a bumped constraint, or vendor the single source file into app/Support with the MIT notice retained. Forking is the lower-risk of the two for auditability.Symfony\Component\Console\Formatter\OutputFormatterStyle registered via $this->output->getFormatter()->setStyle(...), which is fully supported and maintained.Compatibility
$this->output->isDecorated() (Symfony) or stream_isatty(STDOUT) before emitting raw ANSI."wujunze/php-cli-color": "x.y.z") rather than a caret range, since there is no expectation of further releases.composer.json replace/vendor notes if forking, so future maintainers understand the provenance.Sequencing
OutputFormatter for the same output; make a build-vs-depend call on evidence.ConsoleStyle wrapper, style guide, and lint rule (or code-review checklist) banning direct usage.Maintenance
composer outdated noise and possible composer audit policy friction for an abandoned dependency; plan for an allowlist entry or a fork to keep CI green.Support
Scaling
Failure modes
| Failure | Impact | Mitigation |
|---|---|---|
| Escape codes written into log files / CI artifacts | Noisy, occasionally breaks log parsers | Gate on isDecorated() / stream_isatty() |
composer install fails on PHP 8.x platform check |
Blocks builds for the whole team | Fork with corrected constraint, or vendor the file |
| Legacy Windows / minimal CI terminal shows garbage | Cosmetic; degrades operator trust in output | Detect terminal capability; degrade to plain text |
| Upstream disappears entirely | Loss of provenance and license traceability | Fork to internal namespace; retain MIT notice |
| Divergent styling across commands | Inconsistent operator experience | Single ConsoleStyle helper + review checklist |
Ramp-up
OutputFormatter and close the gap with zero new dependencies, or (b) if a specific capability is genuinely missing, vendor ~100 lines into an internal ConsoleStyle helper under MIT attribution. The package is safe to use, but not worth depending on given a seven-year release gap and full overlap with the framework's existing console layer.How can I help you explore Laravel packages today?