本文整理汇总了PHP中Symfony\Component\Console\Style\SymfonyStyle::getVerbosity方法的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyStyle::getVerbosity方法的具体用法?PHP SymfonyStyle::getVerbosity怎么用?PHP SymfonyStyle::getVerbosity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Style\SymfonyStyle
的用法示例。
在下文中一共展示了SymfonyStyle::getVerbosity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execCmd
/**
* @param string $cmd
* @param bool $ignoreErrors
*
* @throws Exception
*/
private function execCmd($cmd, $ignoreErrors = false)
{
$cmd = 'cd ' . $this->workspacePath . ' && ' . $cmd;
if ($this->io->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$this->io->comment($cmd);
}
$process = new Process($cmd);
$process->run(function ($type, $buffer) use($ignoreErrors) {
if (Process::ERR === $type) {
if ($ignoreErrors) {
if ($this->io->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$this->io->comment($buffer);
}
} else {
$this->io->error($buffer);
}
} else {
if ($this->io->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$this->io->comment($buffer);
}
}
});
if (!$ignoreErrors && !$process->isSuccessful()) {
throw new Exception($process->getOutput() . $process->getErrorOutput());
}
}
示例2: execute
/**
* Execute a bash command.
*
* @param array $command
* @param bool $showOutput
*
* @return string
*/
protected function execute(array $command, $showOutput = true)
{
$helper = new ProcessHelper();
$helper->setHelperSet(new HelperSet(['debug_formatter' => new DebugFormatterHelper()]));
// Compute new verbosity
$previousVerbosity = $this->output->getVerbosity();
$verbosity = $showOutput ? OutputInterface::VERBOSITY_DEBUG : OutputInterface::VERBOSITY_QUIET;
// Execute command with defined verbosity
$this->output->setVerbosity($verbosity);
$process = $helper->run($this->output, $command);
$this->output->setVerbosity($previousVerbosity);
return $process->getOutput();
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
$this->io->block('Running server...');
$verbosity = $this->io->getVerbosity();
switch ($verbosity) {
case 16:
$verbosity = 'quiet';
break;
case 32:
$verbosity = 'normal';
break;
case 64:
$verbosity = 'verbose';
break;
case 128:
$verbosity = 'very_verbose';
break;
case 256:
$verbosity = 'debug';
break;
}
$this->io->note('Verbosity is "' . $verbosity . '". To set verbosity, add "-v", "-vv" or "-vvv" end the end of this command.');
$this->socketPort = $this->getContainer()->getParameter('socket_port');
$em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
$logger = $this->getContainer()->get('logger');
$socketUrl = $this->getContainer()->getParameter('socket_server_url');
$webUrl = $this->getContainer()->getParameter('web_server_url');
$webHooks = $em->getRepository('AppBundle:WebHook')->findAll();
$logger->info(count($webHooks) . ' webHook(s)');
$server = new Server($em, $webHooks, $webUrl, $socketUrl, $logger);
$this->killExistingSocketServer();
$ioServer = IoServer::factory(new HttpServer(new WsServer($server)), $this->socketPort);
$logger->info('Run socket server on port ' . $this->socketPort . '...');
$ioServer->run();
}
示例4: createServerProcess
/**
* @param SymfonyStyle $io
* @param string $address
* @param string $webDir
* @param string $router
*
* @return null|\Symfony\Component\Process\Process
*/
protected function createServerProcess(SymfonyStyle $io, $address, $webDir, $router)
{
if (!file_exists($router)) {
$io->error(sprintf('The router script "%s" does not exist', $router));
return null;
}
$finder = new PhpExecutableFinder();
if (($binary = $finder->find()) === false) {
$io->error('Unable to find PHP binary to run server.');
return null;
}
$builder = new ProcessBuilder([$binary, '-S', $address, '-t', $webDir, $router]);
$builder->setTimeout(null);
if ($io->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
$builder->disableOutput();
}
return $builder->getProcess();
}
示例5: verboseLog
/**
* @param string $msg
* @param $color
*/
protected function verboseLog($msg, $color)
{
if ($this->io && $this->io->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
$this->io->comment('<' . $color . '>' . date('[Y-m-d H:i:s]') . $msg . '</' . $color . '>');
}
}