當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ConsoleOutput::write方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Output\ConsoleOutput::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleOutput::write方法的具體用法?PHP ConsoleOutput::write怎麽用?PHP ConsoleOutput::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Output\ConsoleOutput的用法示例。


在下文中一共展示了ConsoleOutput::write方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: writeln

 public function writeln($sprintf)
 {
     $arguments = func_get_args();
     $arguments[0] .= PHP_EOL;
     $message = call_user_func_array("sprintf", $arguments);
     $this->laravelConsoleOutput->write($message);
 }
開發者ID:jlaso,項目名稱:tradukoj-laravel,代碼行數:7,代碼來源:ConsoleOutputAdapter.php

示例2: readline

 /**
  * @return string
  */
 protected function readline()
 {
     $this->output->write($this->getPrompt());
     $line = fgets(STDIN, 1024);
     $line = false === $line || '' === $line ? false : rtrim($line);
     return $line;
 }
開發者ID:nitso,項目名稱:php-sql-console,代碼行數:10,代碼來源:Shell.php

示例3: output

 /**
  * Outputs specified text to the console window
  * You can specify arguments that will be passed to the text via sprintf
  * @see http://www.php.net/sprintf
  *
  * @param string $text Text to output
  * @param array $arguments Optional arguments to use for sprintf
  * @return void
  */
 public function output($text, array $arguments = array())
 {
     if ($arguments !== array()) {
         $text = vsprintf($text, $arguments);
     }
     $this->output->write($text);
 }
開發者ID:sengkimlong,項目名稱:Flow3-Authentification,代碼行數:16,代碼來源:ConsoleOutput.php

示例4: output

 /**
  * Prints a message to console
  *
  * @param $message
  * @param int $tabs
  * @param int $newLine
  */
 public function output($message, $tabs = 1, $newLine = 1)
 {
     //Auto logs to File
     $this->log(strip_tags($message));
     $this->consoleOutput->write(str_repeat("\t", $tabs));
     $this->consoleOutput->write($message);
     // Writes Message to console
     $this->consoleOutput->write(str_repeat(PHP_EOL, $newLine));
     // New Lines
 }
開發者ID:lotzer,項目名稱:facilior,代碼行數:17,代碼來源:ConsoleService.php

示例5: write

 /**
  * Outputs a string to the cli. If you send an array it will implode them
  * with a line break.
  *
  * @param string|array $text the text to output, or array of lines
  * @param bool         $newline
  */
 public static function write($text = '', $newline = false)
 {
     if (is_array($text)) {
         foreach ($text as $line) {
             CLI::write($line);
         }
     } else {
         if (PHP_SAPI == 'cli') {
             static::$output->write($text, $newline);
         } else {
             echo "<h4>{$text}</h4>";
         }
     }
 }
開發者ID:butschster,項目名稱:sugarcrm_dev,代碼行數:21,代碼來源:CLI.php

示例6: execute_commands

/**
 * @param $commands
 * @param \Symfony\Component\Console\Output\ConsoleOutput $output
 *
 * @return boolean
 */
function execute_commands($commands, $output)
{
    foreach ($commands as $command) {
        list($command, $message, $allowFailure) = $command;
        $output->write(sprintf(' - %\'.-70s', $message));
        $return = array();
        if (is_callable($command)) {
            $success = $command($output);
        } else {
            $p = new \Symfony\Component\Process\Process($command);
            $p->setTimeout(null);
            $p->run(function ($type, $data) use(&$return) {
                $return[] = $data;
            });
            $success = $p->isSuccessful();
        }
        if (!$success && !$allowFailure) {
            $output->writeln('<error>KO</error>');
            $output->writeln(sprintf('<error>Fail to run: %s</error>', is_callable($command) ? '[closure]' : $command));
            foreach ($return as $data) {
                $output->write($data, false, OutputInterface::OUTPUT_RAW);
            }
            $output->writeln("If the error is coming from the sandbox,");
            $output->writeln("please report the issue to https://github.com/sonata-project/sandbox/issues");
            return false;
        } else {
            if (!$success) {
                $output->writeln("<info>!!</info>");
            } else {
                $output->writeln("<info>OK</info>");
            }
        }
    }
    return true;
}
開發者ID:NadirZenith,項目名稱:sonata-boilerplate,代碼行數:41,代碼來源:load_data.php

示例7: write

 /**
  * Write an entry to the console and to the provided logger.
  *
  * @param array|string $message
  * @param bool         $newline
  * @param int          $type
  *
  * @return void
  */
 public function write($message, $newline = false, $type = 0)
 {
     if ($this->getLogger()) {
         $this->getLogger()->info($this->getFormatter()->format(strip_tags($message)));
     }
     parent::write($message, $newline, $type);
 }
開發者ID:michaelyin1,項目名稱:Modern-Toolkit,代碼行數:16,代碼來源:Output.php

示例8: createConsoleOutput

 /**
  * @return OutputWriter
  */
 public static function createConsoleOutput()
 {
     $output = new ConsoleOutput();
     return new OutputWriter(function ($message) use($output) {
         $output->write($message, TRUE);
     });
 }
開發者ID:pecinaon,項目名稱:sandbox,代碼行數:10,代碼來源:MigrationsExtension.php

示例9: write

 /**
  * {@inheritdoc}
  */
 public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
 {
     $messages = (array) $messages;
     foreach ($messages as $message) {
         $this->logger->log(200, strip_tags($message));
     }
     reset($messages);
     parent::write($messages, $newline, $options);
 }
開發者ID:relo-san,項目名稱:CommandChainTest,代碼行數:12,代碼來源:ConsoleLoggedOutput.php

示例10: write

 /**
  * Write an entry to the console and to the provided logger.
  *
  * @param array|string $message
  * @param bool         $newline
  * @param int          $type
  *
  * @return void
  */
 public function write($message, $newline = false, $type = 0)
 {
     $messages = (array) $message;
     if ($this->getLogger()) {
         foreach ($messages as $message) {
             $this->getLogger()->info($this->getFormatter()->format(strip_tags($message)));
         }
     }
     parent::write($messages, $newline, $type);
 }
開發者ID:crazycodr,項目名稱:phpDocumentor2,代碼行數:19,代碼來源:Output.php

示例11: execute_commands

/**
 * @param $commands
 * @param \Symfony\Component\Console\Output\ConsoleOutput $output
 * @return void
 */
function execute_commands($commands, $output)
{
    foreach ($commands as $command) {
        $output->writeln(sprintf('<info>Executing : </info> %s', $command));
        $p = new \Symfony\Component\Process\Process($command);
        $exit = $p->run(function ($type, $data) use($output) {
            $output->write($data);
        });
        $output->writeln("");
    }
}
開發者ID:karousn,項目名稱:sandbox,代碼行數:16,代碼來源:load_data.php

示例12: readline

 private function readline($prompt)
 {
     if (function_exists('readline')) {
         $line = readline($prompt);
     } else {
         $this->output->write($prompt);
         $line = fgets(STDIN, 1024);
         $line = !$line && strlen($line) == 0 ? false : rtrim($line);
     }
     return $line;
 }
開發者ID:mpoiriert,項目名稱:nucleus,代碼行數:11,代碼來源:Migrator.php

示例13: write

 public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
 {
     $messagesToLog = (array) $messages;
     foreach ($messagesToLog as $message) {
         if (strlen($message) === 0) {
             continue;
         }
         //$message = strip_tags($this->getFormatter()->format($message));
         $message = strip_tags($message);
         $this->logger->info($message);
     }
     parent::write($messages, $newline, $options);
 }
開發者ID:Mactronique,項目名稱:php_updater,代碼行數:13,代碼來源:MonologOutput.php

示例14: terminate

 /**
  * @inheritdoc
  */
 public function terminate(ResultCollection $collection, ResultCollection $groupedResults)
 {
     $output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);
     $output->write(str_pad("\r", 80, " "));
     $output->writeln('');
     // score
     $score = $collection->getScore();
     //        if($score) {
     foreach ($score->all() as $name => $value) {
         $output->writeln(sprintf('%s %s', str_pad($name, 35, '.'), str_pad($value, 5, ' ', STR_PAD_LEFT) . ' / ' . Scoring::MAX));
     }
     $output->writeln('');
     //        }
 }
開發者ID:truffo,項目名稱:PhpMetrics,代碼行數:17,代碼來源:Cli.php

示例15: createDatabase

 private static function createDatabase(Application $application)
 {
     $output = new ConsoleOutput();
     self::executeCommand($application, 'doctrine:database:drop', array('--force' => true));
     $connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection();
     if ($connection->isConnected()) {
         $connection->close();
     }
     self::executeCommand($application, 'doctrine:database:create');
     $output->write('Drop database...');
     $dropDatabase = self::executeCommand($application, 'doctrine:schema:drop', array('--force' => true));
     if (0 === $dropDatabase) {
         $output->writeln(' Ok.');
     } else {
         $output->writeln('Error: ' . $dropDatabase . '.');
     }
     $output->write('Create database...');
     $createDatabase = self::executeCommand($application, 'doctrine:schema:create');
     if (0 === $createDatabase) {
         $output->writeln(' Ok.');
     } else {
         $output->writeln('Error: ' . $createDatabase . '.');
     }
     $loadFixturesOptions = array('-n' => true);
     $fixtures = static::getFixtures();
     if (count($fixtures)) {
         $loadFixturesOptions['--fixtures'] = $fixtures;
     }
     $output->write('Load fixtures...');
     $loadFixtures = self::executeCommand($application, 'wealthbot:fixtures:load', $loadFixturesOptions);
     if (0 === $loadFixtures) {
         $output->writeln(' Ok.');
     } else {
         $output->writeln('Error: ' . $loadFixtures . '.');
     }
 }
開發者ID:junjinZ,項目名稱:wealthbot,代碼行數:36,代碼來源:ExtendedTestCase.php


注:本文中的Symfony\Component\Console\Output\ConsoleOutput::write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。