Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

add colors when running composer

Discussion in 'General Discussion' started by katmai, Feb 1, 2017.

  1. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    531
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Brno, Czech Republic
    hey guys so this is kinda an odd request. i know i sorted this problem a while ago but i totally forgot how to do it now.

    i have this new centos7 server screencast.com/t/jA8z205a - where when running "composer" the display is all black and white, and i have this other server:

    screencast.com/t/dZJI7eIHa - where the display is colored and the composer running commands output is colored.

    i setup the second server too and i know i enabled something but i honest to god don't remember what i did to have composer colored display.

    can someone give me a hint? ill be in your debt.
     
  2. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    531
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Brno, Czech Republic
    the answer came to me after i posted this thread.

    composer --ansi :)
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm happy to see you were able to find the answer to your question. Thank you for updating us with the outcome.
     
  4. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    531
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Brno, Czech Republic
    I am still curious how you guys are doing it on cPanel though, because the way i did it was create a script that runs composer --ansi whenever i type "composer", however i see that on my cpanel box where there's composer, the colors show without me forcing --ansi :
    - Removed -
     
    #4 katmai, Feb 1, 2017
    Last edited by a moderator: Feb 1, 2017
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    You can review Composer's installation file to see how they have it configured by default at:

    getcomposer.org/installer at master · composer/getcomposer.org · GitHub

    EX:

    Code:
    /**
     * Sets the USE_ANSI define for colorizing output
     *
     * @param array $argv Command-line arguments
     */
    function setUseAnsi($argv)
    {
        // --no-ansi wins over --ansi
        if (in_array('--no-ansi', $argv)) {
            define('USE_ANSI', false);
        } elseif (in_array('--ansi', $argv)) {
            define('USE_ANSI', true);
        } else {
            // On Windows, default to no ANSI, except in ANSICON and ConEmu.
            // Everywhere else, default to ANSI if stdout is a terminal.
            define(
                'USE_ANSI',
                (DIRECTORY_SEPARATOR == '\\')
                    ? (false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'))
                    : (function_exists('posix_isatty') && posix_isatty(1))
            );
        }
    }
    
    /**
    Thank you.
     
Loading...

Share This Page