當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。