当前位置: 首页>>代码示例>>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;未经允许,请勿转载。