本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::setVerbosity方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::setVerbosity方法的具體用法?PHP OutputInterface::setVerbosity怎麽用?PHP OutputInterface::setVerbosity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::setVerbosity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Executes the application.
*
* Available options:
*
* * interactive: Sets the input interactive flag
* * decorated: Sets the output decorated flag
* * verbosity: Sets the output verbosity flag
* * capture_stderr_separately: Make output of stdOut and stdErr separately available
*
* @param array $input An array of arguments and options
* @param array $options An array of options
*
* @return int The command exit code
*/
public function run(array $input, $options = array())
{
$this->input = new ArrayInput($input);
if (isset($options['interactive'])) {
$this->input->setInteractive($options['interactive']);
}
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
if (!$this->captureStreamsIndependently) {
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
if (isset($options['decorated'])) {
$this->output->setDecorated($options['decorated']);
}
if (isset($options['verbosity'])) {
$this->output->setVerbosity($options['verbosity']);
}
} else {
$this->output = new ConsoleOutput(isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL, isset($options['decorated']) ? $options['decorated'] : null);
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
$errorOutput->setFormatter($this->output->getFormatter());
$errorOutput->setVerbosity($this->output->getVerbosity());
$errorOutput->setDecorated($this->output->isDecorated());
$reflectedOutput = new \ReflectionObject($this->output);
$strErrProperty = $reflectedOutput->getProperty('stderr');
$strErrProperty->setAccessible(true);
$strErrProperty->setValue($this->output, $errorOutput);
$reflectedParent = $reflectedOutput->getParentClass();
$streamProperty = $reflectedParent->getProperty('stream');
$streamProperty->setAccessible(true);
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
}
return $this->statusCode = $this->application->run($this->input, $this->output);
}
示例2: doRun
/**
* Runs the current application.
*
* @param InputInterface $input An Input instance
* @param OutputInterface $output An Output instance
*
* @return integer 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$output->writeLn($this->getHeader());
$name = $this->getCommandName($input);
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
$shell = new Shell($this);
$shell->run();
return 0;
}
if (true === $input->hasParameterOption(array('--ansi'))) {
$output->setDecorated(true);
} elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
$output->setDecorated(false);
}
if (true === $input->hasParameterOption(array('--help', '-h'))) {
if (!$name) {
$name = 'help';
$input = new ArrayInput(array('command' => 'help'));
} else {
$this->wantHelps = true;
}
}
if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
$input->setInteractive(false);
}
if (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) {
$inputStream = $this->getHelperSet()->get('dialog')->getInputStream();
if (!posix_isatty($inputStream)) {
$input->setInteractive(false);
}
}
if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
} elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
if (true === $input->hasParameterOption(array('--version', '-V'))) {
$output->writeln($this->getLongVersion());
return 0;
}
if (!$name) {
$name = 'list';
$input = new ArrayInput(array('command' => 'list'));
}
// the command name MUST be the first element of the input
$command = $this->find($name);
$this->runningCommand = $command;
$statusCode = $command->run($input, $output);
$this->runningCommand = null;
# write Footer
$output->writeLn($this->getFooter());
return is_numeric($statusCode) ? $statusCode : 0;
}
示例3: setupOutput
protected function setupOutput()
{
$outputResource = $this->getLogsResource();
$this->output = new StreamOutput($outputResource);
$this->output->setDecorated(false);
$this->output->setVerbosity(true);
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$binDir = $composer->getConfig()->get('bin-dir');
if ($input->getOption('list') || !$input->getArgument('binary')) {
$bins = glob($binDir . '/*');
if (!$bins) {
throw new \RuntimeException("No binaries found in bin-dir ({$binDir})");
}
$this->getIO()->write(<<<EOT
<comment>Available binaries:</comment>
EOT
);
foreach ($bins as $bin) {
// skip .bat copies
if (isset($previousBin) && $bin === $previousBin . '.bat') {
continue;
}
$previousBin = $bin;
$bin = basename($bin);
$this->getIO()->write(<<<EOT
<info>- {$bin}</info>
EOT
);
}
return;
}
$binary = $input->getArgument('binary');
$dispatcher = $composer->getEventDispatcher();
$dispatcher->addListener('__exec_command', $binary);
if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
}
return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
}
示例5: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return integer
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->typeCheck->execute(func_get_args());
$this->isolator->chdir($input->getArgument('path'));
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
$configuration = $this->getApplication()->configurationReader()->read(null, true);
$this->includeLoaders($configuration, $output);
$output->writeln('<info>Checking for correct Typhoon setup...</info>');
$result = $this->analyzer()->analyze($configuration);
if (count($result->issues()) < 1) {
$output->writeln('<info>No problems detected.</info>');
} else {
if (count($result->issuesBySeverity(IssueSeverity::ERROR())) > 0) {
$output->writeln('');
$output->writeln($this->generateErrorBlock($result));
}
if (count($result->issuesBySeverity(IssueSeverity::WARNING())) > 0) {
$output->writeln('');
$output->writeln($this->generateWarningBlock($result));
}
}
if ($result->isError()) {
return 1;
}
return 0;
}
示例6: getLogger
/**
* @param OutputInterface $output
* @return OutputLogger
*/
protected function getLogger(OutputInterface $output)
{
if ($output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
return new OutputLogger($output);
}
示例7: execute
/**
* {@inheritdoc}
*
* @see PlatformCommand::getCurrentEnvironment()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
$process = $this->getHelper('process');
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
if (!is_dir(Platform::rootDir() . '/docker/fg')) {
$process->mustRun($output, ['git', 'clone', 'https://github.com/brendangregg/FlameGraph.git', Platform::rootDir() . '/docker/fg']);
}
if (!is_dir(Platform::rootDir() . '/docker/xhpfg')) {
$process->mustRun($output, ['git', 'clone', 'https://github.com/msonnabaum/xhprof-flamegraphs.git', Platform::rootDir() . '/docker/xhpfg']);
}
$stack = StacksFactory::getStack(Platform::webDir());
switch ($stack->type()) {
case Stacks\Drupal::TYPE:
$this->stdOut->writeln("<comment>Patching Drupal for xhprof</comment>");
$patchProcess = new Process('patch -p1 < ' . CLI_ROOT . '/resources/drupal-enable-profiling.patch', Platform::webDir());
break;
case Stacks\WordPress::TYPE:
$this->stdOut->writeln("<comment>Patching WordPress for xhprof</comment>");
$patchProcess = new Process('patch -p0 < ' . CLI_ROOT . '/resources/wordpress-enable-profiling.patch', Platform::webDir());
break;
default:
throw new \Exception('Stack type not supported yet.');
}
$patchProcess->mustRun();
}
示例8: configureOutputStream
/**
* Configure output stream parameters.
*
* @param OutputInterface $output
*/
protected function configureOutputStream(OutputInterface $output)
{
$verbosity = $this->getOutputVerbosity() ? OutputInterface::VERBOSITY_VERBOSE : OutputInterface::VERBOSITY_NORMAL;
$output->setVerbosity($verbosity);
if (null !== $this->isOutputDecorated()) {
$output->getFormatter()->setDecorated($this->isOutputDecorated());
}
}
示例9: doCommand
protected function doCommand(OutputInterface $output, $verbosity, $command, $args)
{
$oldVerbosity = $output->getVerbosity();
$output->setVerbosity($verbosity);
$c = $this->getApplication()->find($command);
$input = new \Symfony\Component\Console\Input\ArrayInput(array_merge(array('command' => $c), $args));
$c->run($input, $output);
$output->setVerbosity($oldVerbosity);
}
示例10: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
// introspect input without definition
$config = $input->getParameterOption(array('--config', '-c'));
$verbose = $input->getParameterOption(array('--verbose', '-v'));
$bootstrap = $input->getParameterOption(array('--bootstrap', '-b'));
$profile = $input->getParameterOption(array('--profile', '-p'));
if (true == $verbose) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
$container = $this->getContainer();
// event dispatcher
$container['dispatcher'] = new EventDispatcher();
$container['input'] = $input;
$container['output'] = $output;
// config
/**
* Process options
*/
$this->register(new ConfigServiceProvider(), array('config.path' => $config));
if ($profile) {
$container['config.profile'] = $profile;
}
$overrides = array();
if ($input->hasParameterOption(array('--verbose', '-v'))) {
$overrides['verbose'] = true;
}
if ($bootstrap) {
$overrides['bootstrap'] = $bootstrap;
}
$container['config.overrides'] = $overrides;
/**
* Should overwrite the profile with command line options here
*/
$profile = $container['profile'];
if ($profile->bootstrap) {
$inc = function () use($profile) {
require $profile->bootstrap;
};
$inc();
}
// extensions
foreach ($profile->extensions as $name => $options) {
$class = "\\DSpec\\Provider\\" . ucfirst($name) . "ServiceProvider";
if (!class_exists($class)) {
$class = $name;
if (!class_exists($class)) {
throw new \InvalidArgumentException("class:{$class} not found");
}
}
$this->register(new $class(), (array) $options);
}
$container['dspec.command'] = new DSpecCommand($container);
$this->bootProviders();
$this->add($container['dspec.command']);
return parent::doRun($input, $output);
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->isVerbose = OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity();
if (!$this->isVerbose && $this->config->verboseMode) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
$this->isVerbose = true;
}
$this->output = $output;
}
示例12: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->typeCheck->execute(func_get_args());
$this->isolator->chdir($input->getArgument('path'));
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
$configuration = $this->getApplication()->configurationReader()->read(null, true);
$this->includeLoaders($configuration, $output);
$output->writeln('<info>Generating classes...</info>');
$this->generator()->generate($configuration);
$output->writeln('<info>Done.</info>');
}
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!empty($input->getOption('debug')) && $output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
$output->writeln($this->getApplication()->getLongVersion() . "\n", Output::VERBOSITY_VERBOSE);
$formatter = KeyLighter::get()->getFormatter($input->getOption('format')) ?: KeyLighter::get()->getDefaultFormatter();
foreach ($input->getArgument('path') as $filename) {
$this->process($input, $output, $filename, $formatter);
}
}
示例14: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(\Codeception\Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString());
$options = $input->getOptions();
if ($options['debug']) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
}
$options['verbosity'] = $output->getVerbosity();
if (!extension_loaded('curl')) {
throw new \Exception("Codeception requires CURL extension installed to make tests run\n" . "If you are not sure, how to install CURL, pls refer to StackOverflow\n\n" . "Notice: PHP for Apache/Nginx and CLI can have different php.ini files.\n" . "Please make sure that your PHP you run from console has CURL enabled.");
}
$config = Configuration::config($options['config']);
$suite = $input->getArgument('suite');
$test = $input->getArgument('test');
if (!Configuration::isEmpty() && !$test && strpos($suite, $config['paths']['tests']) === 0) {
list($matches, $suite, $test) = $this->matchTestFromFilename($suite, $config['paths']['tests']);
}
if ($options['group']) {
$output->writeln(sprintf("[Groups] <info>%s</info> ", implode(', ', $options['group'])));
}
if ($input->getArgument('test')) {
$options['steps'] = true;
}
if ($test) {
$filter = $this->matchFilteredTestName($test);
$options['filter'] = $filter;
}
$this->codecept = new \Codeception\Codecept((array) $options);
if ($suite and $test) {
$this->codecept->run($suite, $test);
}
if (!$test) {
$suites = $suite ? explode(',', $suite) : Configuration::suites();
$current_dir = Configuration::projectDir();
$executed = $this->runSuites($suites, $options['skip']);
foreach ($config['include'] as $included_config_file) {
Configuration::config($full_path = $current_dir . $included_config_file);
$namespace = $this->currentNamespace();
$output->writeln("\n<fg=white;bg=magenta>\n[{$namespace}]: tests from {$full_path}\n</fg=white;bg=magenta>");
$suites = $suite ? explode(',', $suite) : Configuration::suites();
$executed += $this->runSuites($suites, $options['skip']);
}
if (!$executed) {
throw new \RuntimeException(sprintf("Suite '%s' could not be found", implode(', ', $suites)));
}
}
$this->codecept->printResult();
if (!$input->getOption('no-exit')) {
if ($this->codecept->getResult()->failureCount() or $this->codecept->getResult()->errorCount()) {
exit(1);
}
}
}
示例15: loadCommands
/**
* @param InputInterface $input
* @param OutputInterface $output
* @throws \Exception
*/
public function loadCommands(InputInterface $input, OutputInterface $output)
{
// $application is required to be defined in the register_command scripts
$application = $this->application;
$inputDefinition = $application->getDefinition();
$inputDefinition->addOption(new InputOption('no-warnings', null, InputOption::VALUE_NONE, 'Skip global warnings, show command output only', null));
try {
$input->bind($inputDefinition);
} catch (\RuntimeException $e) {
//expected if there are extra options
}
if ($input->getOption('no-warnings')) {
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
}
require_once __DIR__ . '/../../../core/register_command.php';
if ($this->config->getSystemValue('installed', false)) {
if (\OCP\Util::needUpgrade()) {
$output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
$output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
} elseif ($this->config->getSystemValue('maintenance', false)) {
$output->writeln("ownCloud is in maintenance mode - no app have been loaded");
} else {
OC_App::loadApps();
foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
$appPath = \OC_App::getAppPath($app);
if ($appPath === false) {
continue;
}
\OC::$loader->addValidRoot($appPath);
$file = $appPath . '/appinfo/register_command.php';
if (file_exists($file)) {
require $file;
}
}
}
} else {
$output->writeln("ownCloud is not installed - only a limited number of commands are available");
}
$input = new ArgvInput();
if ($input->getFirstArgument() !== 'check') {
$errors = \OC_Util::checkServer(\OC::$server->getConfig());
if (!empty($errors)) {
foreach ($errors as $error) {
$output->writeln((string) $error['error']);
$output->writeln((string) $error['hint']);
$output->writeln('');
}
throw new \Exception("Environment not properly prepared.");
}
}
}