Colors in PHP CLI

Test in console:

php -r 'echo "\033[31mTEST\0330m'

Test in php file:

echo "\033[32mTEST\033[0m" . PHP_EOL;

Remember to use quotation mark instead of apostrophe.

You can set foreground and background colors.

Color codes:

FG codeBG codeColor
3040Black
3141Red
3242Green
3343Yellow
3444Blue
3545Magenta
3646Cyan
3747White
90100Bright Black (Gray)
91101Bright Red
92102Bright Green
93103Bright Yellow
94104Bright Blue
95105Bright Magenta
96106Bright Cyan
97107Bright White