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


PHP Console::error方法代码示例

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


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

示例1: 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

示例2: export

 /**
  * @inheritdoc
  */
 public function export()
 {
     foreach ($this->messages as $message) {
         if ($message[1] == Logger::LEVEL_ERROR) {
             Console::error($this->formatMessage($message));
         } else {
             Console::output($this->formatMessage($message));
         }
     }
 }
开发者ID:wirwolf,项目名称:yii2-consolelog,代码行数:13,代码来源:ConsoleTarget.php

示例3: actionHandle

 /**
  * @param string $command serialized command object
  * @return string
  */
 public function actionHandle($command)
 {
     try {
         $command = unserialize(base64_decode($command));
         $command->setRunningInBackground(true);
         $this->commandBus->handle($command);
     } catch (\Exception $e) {
         Console::error($e->getMessage());
     }
 }
开发者ID:trntv,项目名称:yii2-command-bus,代码行数:14,代码来源:BackgroundBusController.php

示例4: actionReplaceSourceLanguage

 /**
  * @param $path
  * @param bool $newSourceLanguage
  * @param bool $configFile
  * @throws Exception
  */
 public function actionReplaceSourceLanguage($configFile, $newSourceLanguage = false)
 {
     $config = ['translator' => 'Yii::t', 'overwrite' => false, 'removeUnused' => false, 'sort' => false, 'format' => 'php'];
     $configFile = Yii::getAlias($configFile);
     if (!is_file($configFile)) {
         throw new Exception("The configuration file does not exist: {$configFile}");
     }
     $config = array_merge($config, require $configFile);
     if (!is_dir($config['sourcePath'])) {
         throw new Exception("The source path {$config['sourcePath']} is not a valid directory.");
     }
     $files = FileHelper::findFiles(realpath($config['sourcePath']), $config);
     $unremoved = [];
     foreach ($files as $fileName) {
         if (!is_array($config['translator'])) {
             $translator = [$config['translator']];
         }
         foreach ($translator as $currentTranslator) {
             $n = 0;
             $subject = file_get_contents($fileName);
             $replacedSubject = preg_replace_callback('/\\b(\\\\)?' . $currentTranslator . '\\s*\\(\\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\\s*,\\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\\s*[,\\)]/s', function ($matches) use($newSourceLanguage, $fileName, &$unremoved) {
                 $category = substr($matches[2], 1, -1);
                 $message = $matches[3];
                 if ($newSourceLanguage !== false) {
                     $message = eval("return {$message};");
                     $result = str_replace($message, Yii::t($category, $message, [], $newSourceLanguage), $matches[0]);
                 } else {
                     if (strpos($matches[0], ')') != strlen($matches[0]) - 1) {
                         $unremoved[$fileName][] = $message;
                         $result = $matches[0];
                     } else {
                         $result = $message;
                     }
                 }
                 return $result;
             }, $subject, -1, $n);
             if (@file_put_contents($fileName, $replacedSubject) !== false) {
                 Console::output("File: {$fileName}; Translator: {$currentTranslator}; Affected: {$n}");
             } else {
                 Console::error("File: {$fileName}; Translator: {$currentTranslator}; Affected: {$n}");
             }
         }
     }
     if ($newSourceLanguage == false && !empty($unremoved)) {
         Console::output('Messages with params, can`t be removed by this tool. Remove it manually');
         foreach ($unremoved as $fileName => $messages) {
             $messages = implode(PHP_EOL, $messages);
             Console::output("{$fileName}:" . PHP_EOL . $messages);
         }
     }
 }
开发者ID:Sywooch,项目名称:AVSProduct,代码行数:57,代码来源:ExtendedMessageController.php

示例5: execute

 public function execute($command, $params = [])
 {
     $command = strtr($command, $params);
     $exec = $this->getExec();
     try {
         if ($this->getIsVerbose()) {
             Console::output("Executing {$command}");
         }
         $result = $exec($command);
         if ($this->getIsVerbose()) {
             Console::output($result);
         }
         return $result;
     } catch (\RuntimeException $e) {
         Console::error($e->getMessage());
         return false;
     }
 }
开发者ID:trntv,项目名称:yii2-deploy,代码行数:18,代码来源:Server.php

示例6: onError

 /**
  * @param $exception
  * @param $job
  */
 protected function onError($job, \Exception $exception = null)
 {
     Console::error("Job ID#{$job['id']}: {$exception->getMessage()}");
 }
开发者ID:trntv,项目名称:yii2-command-bus,代码行数:8,代码来源:QueueBusController.php

示例7: runTasks

 protected function runTasks()
 {
     foreach ($this->_tasks as $k => $id) {
         Console::output(sprintf('Running task "%s" (%d/%d)', $id, $k + 1, count($this->_tasks)));
         $result = $this->_container->get("tasks.{$id}")->run($this->_container, $this);
         if ($result === false) {
             Console::error(sprintf('Task "%s" failed.', $id));
             return false;
         }
     }
     return true;
 }
开发者ID:trntv,项目名称:yii2-deploy,代码行数:12,代码来源:DeployController.php


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