Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to enable coloured messages for PHP CLI on console (Mac OS X, latest PHP/Apache from MacPorts)?

export CLICOLOR=1
export LSCOLORS=gxfxcxdxbxegedabagacad

doesn't seem to be enough, all PHP CLI produced output is colourless on the console. Would be good if the result looks like on the XAMPP PHP instance. Any ideas?

share|improve this question

closed as off-topic by Sven Jun 6 at 17:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Sven
If this question can be reworded to fit the rules in the help center, please edit the question.

Huh? The $CLICOLOR and $LSCOLORS environment variables are for the ls command and has nothing at all to do with PHP. – DerfK Jul 21 '12 at 17:49
What leads you to believe that PHP supports color? What exactly are you expecting yo xolorize? – Zoredache Jul 21 '12 at 18:37
@Zoredache I'm used to get coloured output in the Symfony development that has scaffolding support on console, also tasks and TDD. It considerably improves the readability. – Ain Jul 21 '12 at 22:35

In order to get the colour on your console with PHP CLI, php5-posix module has to be installed. With MacPorts the following command does the job:

sudo port install php5-posix

Enabling colour on the console for the PHP output will hugely improve the readability in Symfony projects for instance.

share|improve this answer
Thanks - this worked perfectly. Note, port now asks you use the specific minor version php54-posix, php56-posix etc. – scipilot Nov 13 '15 at 2:38

Using Mac Ports, on OS X (10.11.+) if you have PHP 7, you can do:

sudo port install php7-posix

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.