当前位置: 首页>>代码示例>>PHP>>正文


PHP Console::ansiFormat方法代码示例

本文整理汇总了PHP中yii\helpers\Console::ansiFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::ansiFormat方法的具体用法?PHP Console::ansiFormat怎么用?PHP Console::ansiFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Console的用法示例。


在下文中一共展示了Console::ansiFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveMessagesToPHP

 /**
  * @inheritdoc
  */
 protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused)
 {
     $dirNameBase = $dirName;
     foreach ($messages as $category => $msgs) {
         /**
          * Fix Directory
          */
         $module = $this->getModuleByCategory($category);
         if ($module !== null) {
             // Use Module Directory
             $dirName = str_replace(Yii::getAlias("@humhub/messages"), $module->getBasePath() . '/messages', $dirNameBase);
             preg_match('/.*?Module\\.(.*)/', $category, $result);
             $category = $result[1];
         } else {
             // Use Standard HumHub Directory
             $dirName = $dirNameBase;
         }
         $file = str_replace("\\", '/', "{$dirName}/{$category}.php");
         $path = dirname($file);
         FileHelper::createDirectory($path);
         $msgs = array_values(array_unique($msgs));
         $coloredFileName = Console::ansiFormat($file, [Console::FG_CYAN]);
         $this->stdout("Saving messages to {$coloredFileName}...\n");
         $this->saveMessagesCategoryToPHP($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused);
     }
 }
开发者ID:freddykr,项目名称:humhub,代码行数:29,代码来源:MessageController.php

示例2: startHead

 public function startHead($controller, $headType, $headId, $restarting)
 {
     if (!$restarting) {
         // Console::output(Console::ansiFormat('Starting ' . $headId, [Console::FG_CYAN]));
     } else {
         // Console::output(Console::ansiFormat('Restarting ' . $headId, [Console::FG_CYAN]));
     }
     $_this = $this;
     $process = new \React\ChildProcess\Process($this->getSubCommand($controller, [$headType, $headId]));
     $process->on('exit', function ($exitCode, $termSignal) use(&$_this, &$controller, $headType, $headId) {
         if ($exitCode !== 0) {
             Console::stderr(Console::ansiFormat("Broadcast head {$headType}:{$headId} exited with error code {$exitCode}", [Console::FG_RED]));
             sleep(10);
         }
         if (static::isPaused()) {
             Yii::$app->end(0);
         }
         $_this->_heads[$headId] = $_this->startHead($controller, $headType, $headId, true);
     });
     $this->loop->addTimer(0.0001, function ($timer) use($process, &$_this) {
         $process->start($timer->getLoop());
         $process->stdout->on('data', function ($output) use($_this) {
             $stdout = fopen('php://stdout', 'w+');
             fwrite($stdout, $output);
         });
         $process->stderr->on('data', function ($output) use($_this) {
             $stderr = fopen('php://stderr', 'w+');
             fwrite($stderr, $output);
         });
     });
     sleep(5);
     return $process;
 }
开发者ID:psesd,项目名称:sensor-hub,代码行数:33,代码来源:Daemon.php

示例3: actionIndex

 public function actionIndex()
 {
     $this->stdout('Description goes here.' . PHP_EOL);
     $helpCommand = Console::ansiFormat("yii help dota2api/economy", [Console::FG_CYAN]);
     $this->stdout("Use {$helpCommand} to get usage info." . PHP_EOL);
     return self::EXIT_CODE_NORMAL;
 }
开发者ID:aldegtyarev,项目名称:fantasy,代码行数:7,代码来源:EconomyController.php

示例4: stderr

 /**
  * Prints a string to STDERR.
  *
  * @param string $string the string to print
  * @return int|boolean Number of bytes printed or false on error
  */
 public static function stderr($string)
 {
     $args = func_get_args();
     array_shift($args);
     $string = parent::ansiFormat($string, $args) . "\n";
     return parent::stderr($string);
 }
开发者ID:delagics,项目名称:yii2-app-another,代码行数:13,代码来源:Console.php

示例5: stderr

 protected function stderr($string)
 {
     if (Console::streamSupportsAnsiColors(\STDOUT)) {
         $string = Console::ansiFormat("    Error: " . $string, [Console::FG_RED]);
     }
     return fwrite(\STDERR, $string);
 }
开发者ID:inblank,项目名称:yii2-activeuser,代码行数:7,代码来源:Migration.php

示例6: showErrors

 /**
  * Show errors
  * @param array $errors array of errors string
  * @throws yii\base\ExitException
  */
 protected function showErrors($errors)
 {
     foreach ((array) $errors as $err) {
         Console::error(Console::ansiFormat(Yii::t('activeuser_backend', "Error") . ": ", [Console::FG_RED]) . $err[0]);
     }
     yii::$app->end();
 }
开发者ID:inblank,项目名称:yii2-activeuser,代码行数:12,代码来源:ConsoleController.php

示例7: message

 /**
  * message
  *
  * @param string $string
  * @access private
  * @return integer|null
  */
 private function message($string)
 {
     if (!empty($string) && !$this->quiet) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
         return Console::stdout($string);
     }
 }
开发者ID:dmitriy-luch,项目名称:yii2-asset-clean,代码行数:16,代码来源:AssetController.php

示例8: stderr

 /**
  * Prints a string to STDERR.
  *
  * @param string $string the string to print
  * @return int|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) . "\n";
     }
     return Console::stderr($string);
 }
开发者ID:delagics,项目名称:yii2-app-another,代码行数:15,代码来源:Controller.php

示例9: formatMessage

 /**
  * Colorizes a message for console output.
  * @param string $message the message to colorize.
  * @param array $format the message format.
  * @return string the colorized message.
  * @see Console::ansiFormat() for details on how to specify the message format.
  */
 protected function formatMessage($message, $format = [Console::FG_RED, Console::BOLD])
 {
     $stream = PHP_SAPI === 'cli' ? \STDERR : \STDOUT;
     // try controller first to allow check for --color switch
     if (Yii::$app->controller instanceof \yii\console\Controller && Yii::$app->controller->isColorEnabled($stream) || Yii::$app instanceof \yii\console\Application && Console::streamSupportsAnsiColors($stream)) {
         $message = Console::ansiFormat($message, $format);
     }
     return $message;
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:16,代码来源:ErrorHandler.php

示例10: stdout

 public function stdout($string)
 {
     if (Console::streamSupportsAnsiColors(STDOUT)) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
     }
     return Console::stdout($string);
 }
开发者ID:filsh,项目名称:yii2-platform,代码行数:9,代码来源:HostRegexpConsoleRule.php

示例11: _initLanguageElements

 /**
  * Initializing $_languageElements array.
  * @param array $languageSourceIds
  */
 private function _initLanguageElements($languageSourceIds)
 {
     $languageSources = LanguageSource::findAll(['id' => $languageSourceIds]);
     foreach ($languageSources as $languageSource) {
         $this->_languageElements[$languageSource->category][$languageSource->message] = $languageSource->id;
         $category = Console::ansiFormat($languageSource->category, [Console::FG_RED]);
         $message = Console::ansiFormat($languageSource->message, [Console::FG_RED]);
         $this->_scanner->stdout('category: ' . $category . ', message: ' . $message);
     }
 }
开发者ID:maxxer,项目名称:yii2-translate-manager,代码行数:14,代码来源:Optimizer.php

示例12: output

 /**
  * Helper method for writting console application output, include before and after wrappers.
  *
  * @param string $message The message which is displayed
  * @param string $color   A color from \yii\helpers\Console::FG_GREEN;
  * @param return void
  */
 protected function output($message, $color = null)
 {
     $format = [];
     if (!$this->isMuted()) {
         if ($color !== null) {
             $format[] = $color;
         }
         echo Console::ansiFormat("\r" . $message . "\n", $format);
     }
 }
开发者ID:gitter-badger,项目名称:luya,代码行数:17,代码来源:Controller.php

示例13: output

 /**
  * 
  * @param string $string
  * @return string
  */
 public function output($string)
 {
     if ($this->isColorEnabled()) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
     }
     $b = Console::stdout($string);
     echo PHP_EOL;
     return $b;
 }
开发者ID:jlorente,项目名称:yii2-app-advanced-template,代码行数:16,代码来源:Controller.php

示例14: write

 public static function write($path, $content)
 {
     if (file_exists($path)) {
         $old = file_get_contents($path);
         if ($old === $content) {
             return;
         }
     }
     file_put_contents($path, $content);
     Console::stdout(Console::ansiFormat("written file: {$path}\n", [Console::FG_YELLOW]));
 }
开发者ID:hiqdev,项目名称:chkipper,代码行数:11,代码来源:File.php

示例15: log

 /**
  * Logs a message to console and then to yii\log\Logger.
  */
 public function log($message, $level, $category = 'application')
 {
     if ($level <= $this->getSpamLevel()) {
         $style = self::$styles[$level];
         if ($style) {
             $message = Console::ansiFormat($message, $style);
         }
         Console::stdout($message . "\n");
     }
     parent::log($message, $level, $category);
 }
开发者ID:hiqdev,项目名称:hidev,代码行数:14,代码来源:Logger.php


注:本文中的yii\helpers\Console::ansiFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。