PHPackages                             localgod/console-color - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. localgod/console-color

AbandonedArchivedLibrary[CLI &amp; Console](/categories/cli)

localgod/console-color
======================

Tool for working with console colors

v1.0.3(4y ago)4821MITPHPPHP &gt;=8.0CI passing

Since Jun 19Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/localgod/console-color)[ Packagist](https://packagist.org/packages/localgod/console-color)[ Docs](http://localgod.github.io/console-color/)[ RSS](/packages/localgod-console-color/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

[![Main](https://github.com/localgod/console-color/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/localgod/console-color/actions/workflows/php.yml)[![Latest Stable Version](https://camo.githubusercontent.com/6420b5f01a7e236a3fabc3fd303ddf9677c9fdf1ebc72cacfca4a35b59609ffb/68747470733a2f2f706f7365722e707567782e6f72672f6c6f63616c676f642f636f6e736f6c652d636f6c6f722f762f737461626c65)](https://packagist.org/packages/localgod/console-color)[![License](https://camo.githubusercontent.com/3a55ba96a0912cae81fe93dd755af00760758df211ef89972c300c53031a13a3/68747470733a2f2f706f7365722e707567782e6f72672f6c6f63616c676f642f636f6e736f6c652d636f6c6f722f6c6963656e7365)](https://packagist.org/packages/localgod/console-color)

Console Color
=============

[](#console-color)

**console-color** makes it simple to work with ANSI color codes in you console.

Base methods
------------

[](#base-methods)

**escape($string)**: Escapes % so they don't get interpreted as color codes; Takes a string as an argument and returns the escaped string.

**convert($string, $colored = true))**: Transform color codes whithin supplied string into ANSI control codes

Magic methods
-------------

[](#magic-methods)

For each of the colors supported you can call:

- {colorname}Normal($string)
- {colorname}Bright($string)
- {colorname}Background($string)

to quickly format the string accordingly.

Code conversion table
---------------------

[](#code-conversion-table)

    Normal Bright Background     Black %k %K %0   Red %r %R %1   Green %g %G %2   Yellow %y %Y %3   Blue %b %B %4   Magenta %m %M %5   Cyan %c %C %6   White %w %W %7  CodeEffect%FBlinking, Flashing%UUnderline%8Reverse%\_,%9Bold%nResets the color%%A single %Examples
--------

[](#examples)

```
use Localgod\Console\Color;
// Let's add a little color to the world
// %n resets the color so the following stuff doesn't get messed up
print Color::convert("%bHello World!%n\n");
// Paint it red
print Color::redNormal("Paint it red!\n");
// Colorless mode, in case you need to strip colorcodes off a text
print Color::convert("%rHello World!%n\n", false);
// The uppercase version makes a colorcode bold/bright
print Color::convert("%BHello World!%n\n");
// To print a %, you use %%
print Color::convert("3 out of 4 people make up about %r75%% %nof the world population.\n");
// Or you can use the escape() method.
print Color::convert("%y".Color::escape('If you feel that you do everying wrong, be random, there\'s a 50% Chance of making the right decision.')."%n\n");
```

Inspiration
-----------

[](#inspiration)

This projects is a reimplementation of the ideas used in [http://pear.php.net/package/Console\_Color/](http://pear.php.net/package/Console_Color/)

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance40

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 57.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~597 days

Total

4

Last Release

1818d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ad971c586a3020fb32c18801008a04b899f83efbc76f244a7e4128096c28b1a?d=identicon)[localgod](/maintainers/localgod)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (41 commits)")[![localgod](https://avatars.githubusercontent.com/u/1308965?v=4)](https://github.com/localgod "localgod (30 commits)")

---

Tags

phpconsole-color

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/localgod-console-color/health.svg)

```
[![Health](https://phpackages.com/badges/localgod-console-color/health.svg)](https://phpackages.com/packages/localgod-console-color)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M318](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M18](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
