3

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?

Ain
  • 188
  • 7
  • 1
    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

2 Answers2

6

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.

Ain
  • 188
  • 7
  • 1
    Thanks - this worked perfectly. Note, port now asks you use the specific minor version php54-posix, php56-posix etc. – scipilot Nov 13 '15 at 02:38
0

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

sudo port install php7-posix

Thiago Pereira
  • 201
  • 2
  • 4