本文整理匯總了PHP中Symfony\Component\Console\Output\ConsoleOutput::getFormatter方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleOutput::getFormatter方法的具體用法?PHP ConsoleOutput::getFormatter怎麽用?PHP ConsoleOutput::getFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\ConsoleOutput
的用法示例。
在下文中一共展示了ConsoleOutput::getFormatter方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: configureOutput
/**
* Configure the console output with custom styles.
*/
protected function configureOutput()
{
$this->output = new ConsoleOutput();
$this->output->getFormatter()->setStyle('path', new OutputFormatterStyle('green', null, ['bold']));
$this->output->getFormatter()->setStyle('time', new OutputFormatterStyle('cyan', null, ['bold']));
$this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(null, null, ['bold']));
}
示例2: run
public function run(InputInterface $input = null, OutputInterface $output = null)
{
if (null === $output) {
$output = new ConsoleOutput();
}
$output->getFormatter()->getStyle('info')->setForeground('magenta');
$output->getFormatter()->getStyle('comment')->setForeground('cyan');
return parent::run($input, $output);
}
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$home = getenv('HOME');
if (!$home) {
throw new \RuntimeException("'HOME' environment variable must be set for Cloud Drive to properly run.");
}
$this->configPath = rtrim($home, '/') . '/.cache/clouddrive-php/';
if (!file_exists($this->configPath)) {
mkdir($this->configPath, 0777, true);
}
$this->configFile = "{$this->configPath}config.json";
$this->input = $input;
$this->output = $output;
// Set up basic styling
$this->output->getFormatter()->setStyle('blue', new OutputFormatterStyle('blue'));
$this->readConfig();
$this->main();
}
示例4: __construct
/**
* Creates and initializes the SymfonyConsoleOutput instance
*
* @return void
*/
public function __construct()
{
$this->output = new SymfonyConsoleOutput();
$this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(NULL, NULL, array('bold')));
$this->output->getFormatter()->setStyle('i', new OutputFormatterStyle('black', 'white'));
$this->output->getFormatter()->setStyle('u', new OutputFormatterStyle(NULL, NULL, array('underscore')));
$this->output->getFormatter()->setStyle('em', new OutputFormatterStyle(NULL, NULL, array('reverse')));
$this->output->getFormatter()->setStyle('strike', new OutputFormatterStyle(NULL, NULL, array('conceal')));
$this->output->getFormatter()->setStyle('error', new OutputFormatterStyle('red'));
$this->output->getFormatter()->setStyle('success', new OutputFormatterStyle('green'));
}
示例5: install
/**
* install
*
* @return void
*/
public static function install()
{
$output = new ConsoleOutput();
$style = new OutputFormatterStyle('green');
$output->getFormatter()->setStyle('green', $style);
$assets = array('resources/cache', 'resources/log', 'web/assets');
foreach ($assets as $asset) {
self::createAndChmod($asset, 0777);
$output->writeln(sprintf('<green>Generating "%s" asset dir</green>', $asset));
}
exec('php console assetic:dump');
}
示例6: index
/**
* {@inheritdoc}
*/
public function index()
{
$style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink'));
$output = new ConsoleOutput();
$output->getFormatter()->setStyle('fire', $style);
$fileContents = $this->searchService->getFileContents();
foreach ($fileContents as $content) {
$output->writeln('<info>Indexing File & Contents: </info><comment>' . $content['path'] . '</comment>');
/**
* @var \Symfony\Component\Finder\SplFileInfo $file
*/
$this->createIndex($content['title'], $content['file_contents'], $content['path']);
}
}
示例7: handle
public function handle(Args $args, IO $io, Command $command)
{
$output = new ConsoleOutput();
$style = new OutputFormatterStyle('white', 'black', array('bold'));
if ($args->getArgument('package') == '') {
$output->writeln(Cpm\message::USAGE);
exit;
}
if (!file_exists('composer.json')) {
$output->writeln(Cpm\message::NOComposerJSON);
}
$json = file_get_contents('composer.json');
$array = json_decode($json, TRUE);
$datas = $array['require'];
foreach ($datas as $data) {
$output->getFormatter()->setStyle('bold', $style);
$output->writeln('<bold>' . $data->name . '</>' . ' ' . $data->description);
$output->writeln($data->keywords);
}
return 0;
}
示例8: handle
public function handle(Args $args, IO $io, Command $command)
{
$table = new Table();
$table->setHeaderRow(array('Name', 'Description'));
$output = new ConsoleOutput();
$style = new OutputFormatterStyle('white', 'black', array('bold'));
if ($args->getArgument('package') == '') {
$output->writeln(Cpm\message::USAGE);
exit;
}
$limit = $args->getOption('limit');
$limit_str = $limit ? 'limit ' . $limit : '';
$q = $args->getArgument('package');
$datas = R::findAll('repo', ' name LIKE ? order by download_monthly desc,favers desc,download_total desc' . $limit_str, ['%' . $q . '%']);
foreach ($datas as $data) {
$output->getFormatter()->setStyle('bold', $style);
// $output->writeln('<bold>'.$data->name.'</>'.' '.$data->description);
// $output->writeln($data->keywords);
$table->addRow(array("(" . $data->favers . ")" . $data->name, $data->description));
}
$table->render($io);
return 0;
}
示例9: ConsoleOutput
<?php
include 'vendor/autoload.php';
use RedBeanPHP\R;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Output\ConsoleOutput;
R::setup('sqlite:db/ppm.db');
$output = new ConsoleOutput();
$style = new OutputFormatterStyle('white', 'black', array('bold'));
if (!isset($argv[1])) {
$output->writeln(Cpm\message::USAGE);
exit;
}
$q = $argv[1];
$datas = R::findAll('repo', ' name LIKE ? order by download_total desc', ['%' . $q . '%']);
$a = array();
foreach ($datas as $data) {
$output->getFormatter()->setStyle('bold', $style);
$output->writeln('<bold>' . $data->name . '</bold>' . ' ' . $data->description);
$output->writeln($data->keywords);
}
示例10: testConstructor
public function testConstructor()
{
$output = new ConsoleOutput(Output::VERBOSITY_QUIET, true);
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
$this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
}
示例11: getPrompt
/**
* @return string
*/
protected function getPrompt()
{
// using the formatter here is required when using readline
return $this->output->getFormatter()->format($this->application->getPrompt() . ' > ');
}