yii\console\Controller::stderr PHP Method

stderr() public method

You may optionally format the string with ANSI codes by passing additional parameters using the constants defined in [[\yii\helpers\Console]]. Example: $this->stderr('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE);
public stderr ( string $string ) : integer | boolean
$string string the string to print
return integer | boolean Number of bytes printed or false on error
    public function stderr($string)
    {
        if ($this->isColorEnabled(\STDERR)) {
            $args = func_get_args();
            array_shift($args);
            $string = Console::ansiFormat($string, $args);
        }
        return fwrite(\STDERR, $string);
    }

Usage Example

 /**
  * If in daemon mode - no write to console
  *
  * @param string $string
  *
  * @return int
  */
 public function stderr($string)
 {
     if (!$this->demonize && is_resource(\STDERR)) {
         return parent::stderr($string);
     } else {
         return false;
     }
 }