本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::setEmptyBarCharacter方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::setEmptyBarCharacter方法的具体用法?PHP ProgressBar::setEmptyBarCharacter怎么用?PHP ProgressBar::setEmptyBarCharacter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::setEmptyBarCharacter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var ImportAddressService $importAddressService */
$importAddressService = $this->getHelper('container')->getByType('StreetApi\\Services\\ImportAddressService');
$cityId = $input->getArgument('cityId');
$xmlFile = simplexml_load_file($importAddressService->getRootDir() . '/../adresy.xml');
if (!$xmlFile) {
$output->writeln(PHP_EOL . '<error>Missing source file!</error>');
return 1;
}
try {
$output->writeLn('<info>Start importing addresses</info>');
$totalCount = $xmlFile->count();
$output->writeln(PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL);
$progressBar = new ProgressBar($output, $totalCount);
$progressBar->setFormat('%message%' . PHP_EOL . '%bar% %percent:3s% %' . PHP_EOL . 'count: %current%/%max%' . PHP_EOL . 'time: %elapsed:6s%/%estimated:-6s%' . PHP_EOL);
$progressBar->setBarCharacter('<info>■</info>');
$progressBar->setEmptyBarCharacter(' ');
$progressBar->setProgressCharacter('');
$progressBar->setRedrawFrequency(ceil($totalCount / 100));
$progressBar->start();
$importAddressService->import($xmlFile, $progressBar, $cityId);
$output->writeLn(PHP_EOL . '<info>Importing addresses finished</info>');
return 0;
} catch (\Exception $e) {
$output->writeLn('<error>' . $e->getMessage() . '</error>');
return 1;
}
}
示例2: createProgressBar
/**
* @param OutputInterface $output
* @param int $length
*
* @return ProgressBar
*/
protected function createProgressBar(OutputInterface $output, $length = 10)
{
$progress = new ProgressBar($output);
$progress->setBarCharacter('<info>|</info>');
$progress->setEmptyBarCharacter(' ');
$progress->setProgressCharacter('|');
$progress->start($length);
return $progress;
}
示例3: create
public static function create(OutputInterface $output)
{
$bar = new ProgressBar($output);
$bar->setBarCharacter('<fg=green>=</>');
$bar->setEmptyBarCharacter('<fg=red>=</>');
$bar->setProgressCharacter('>');
$bar->setBarWidth(40);
$bar->setFormat("%message%\n [%bar%] %percent:3s%%\n%elapsed:6s%/%estimated:-6s% %memory:6s%\n");
return $bar;
}
示例4: getProgressBar
/**
* @param OutputInterface $output
*
* @return \Symfony\Component\Console\Helper\ProgressBar
*/
private function getProgressBar(OutputInterface $output)
{
$bar = new ProgressBar($output);
$bar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %memory:6s%');
$bar->setBarCharacter('<comment>=</comment>');
$bar->setEmptyBarCharacter(' ');
$bar->setProgressCharacter('|');
$bar->setBarWidth(50);
return $bar;
}
示例5: logTask
/**
* @param string $message
*/
public function logTask($message)
{
$this->clearLine();
$this->output->writeln('<fg=blue;options=bold> > ' . $message . " </fg=blue;options=bold>");
if ($this->output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) {
$this->progress = new ProgressBar($this->output);
$this->progress->setEmptyBarCharacter(' ');
$this->progress->setBarCharacter('-');
$this->progress->start();
}
}
示例6: barSetup
/**
* Setting custom formatting for the progress bar
* @param object $bar Symfony ProgressBar instance
* @return object $bar Symfony ProgressBar instance
*/
public function barSetup(ProgressBar $bar)
{
// the finished part of the bar
$bar->setBarCharacter('<comment>=</comment>');
// the unfinished part of the bar
$bar->setEmptyBarCharacter('-');
// the progress character
$bar->setProgressCharacter('>');
// the 'layout' of the bar
$bar->setFormat(' %current%/%max% [%bar%] %percent:3s%% ');
return $bar;
}
示例7: build
/**
* @return \Symfony\Component\Console\Helper\ProgressBar
*/
public function build()
{
$this->setupFormat();
$progressBar = new ProgressBar($this->output, $this->count);
$progressBar->setMessage($this->barTitle, 'barTitle');
$progressBar->setBarWidth(20);
if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
$progressBar->setBarCharacter("[32m◼[0m");
$progressBar->setEmptyBarCharacter("[31m◼[0m");
$progressBar->setProgressCharacter("[32m▶[0m");
$progressBar->setBarWidth(50);
}
return $progressBar;
}
示例8: getProgressBar
protected function getProgressBar($nbIteration, $message)
{
$bar = new ProgressBar($this->output, $nbIteration);
ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) {
static $i = 0;
$mem = memory_get_usage();
$colors = $i++ ? '41;37' : '44;37';
return "[" . $colors . 'm ' . Helper::formatMemory($mem) . " [0m";
});
$bar->setFormat(" [44;37m %title:-38s% [0m\n %current%/%max% %bar% %percent:3s%%\n 🏁 %remaining:-10s% %memory:37s%\n");
$bar->setBarCharacter("[32m●[0m");
$bar->setEmptyBarCharacter("[31m●[0m");
$bar->setMessage($message, 'title');
$bar->start();
return $bar;
}
示例9: downloadFile
/**
* Download a file from the URL to the destination.
*
* @param string $url Fully qualified URL to the file.
* @param bool $progress Show the progressbar when downloading.
*/
public function downloadFile($url, $progress = true)
{
/** @var ProgressBar|null $progressBar */
$progressBar = null;
$downloadCallback = function ($size, $downloaded, $client, $request, Response $response) use(&$progressBar) {
// Don't initialize the progress bar for redirects as the size is much smaller.
if ($response->getStatusCode() >= 300) {
return;
}
if (null === $progressBar) {
ProgressBar::setPlaceholderFormatterDefinition('max', function (ProgressBar $bar) {
return $this->formatSize($bar->getMaxSteps());
});
ProgressBar::setPlaceholderFormatterDefinition('current', function (ProgressBar $bar) {
return str_pad($this->formatSize($bar->getProgress()), 11, ' ', STR_PAD_LEFT);
});
$progressBar = new ProgressBar($this->output, $size);
$progressBar->setFormat('%current%/%max% %bar% %percent:3s%%');
$progressBar->setRedrawFrequency(max(1, floor($size / 1000)));
$progressBar->setBarWidth(60);
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$progressBar->setEmptyBarCharacter('░');
// light shade character \u2591
$progressBar->setProgressCharacter('');
$progressBar->setBarCharacter('▓');
// dark shade character \u2593
}
$progressBar->start();
}
$progressBar->setProgress($downloaded);
};
$client = $this->getGuzzleClient();
if ($progress) {
$this->output->writeln(sprintf("\n Downloading %s...\n", $url));
$client->getEmitter()->attach(new Progress(null, $downloadCallback));
}
$response = $client->get($url);
$tmpFile = $this->filesystemHelper->newTempFilename();
$this->fs->dumpFile($tmpFile, $response->getBody());
if (null !== $progressBar) {
$progressBar->finish();
$this->output->writeln("\n");
}
return $tmpFile;
}
示例10: set_task_count
/**
* {@inheritdoc}
*/
public function set_task_count($task_count, $restart = false)
{
parent::set_task_count($task_count, $restart);
if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
$this->progress_bar = $this->io->createProgressBar($task_count);
$this->progress_bar->setFormat(" %current:3s%/%max:-3s% %bar% %percent:3s%%\n" . " %message%\n");
$this->progress_bar->setBarWidth(60);
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->progress_bar->setEmptyBarCharacter('░');
// light shade character \u2591
$this->progress_bar->setProgressCharacter('');
$this->progress_bar->setBarCharacter('▓');
// dark shade character \u2593
}
$this->progress_bar->setMessage('');
$this->io->newLine(2);
$this->progress_bar->start();
}
}
示例11: onStart
/**
* @param array $data
*/
protected function onStart(array $data)
{
$format = isset($this->options['format']) ? $this->options['format'] : 'normal';
if (isset($data['total']) && $data['total'] > 0) {
$maxSteps = (int) $data['total'];
unset($data['total']);
} else {
$maxSteps = 1;
}
$progress = new ProgressBar($this->output, $maxSteps);
$progress->setFormat($format);
$progress->setEmptyBarCharacter(' ');
$progress->setProgressCharacter(':');
foreach ($data as $key => $value) {
$progress->setMessage($value, $key);
}
$progress->start();
$this->progress = $progress;
}
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var FormatterHelper $formatter */
$formatter = $this->getHelper('formatter');
$message = $formatter->formatSection('Section', 'Hello!', 'comment');
$output->writeln($message);
$blockMessage = $formatter->formatBlock(['Good luck!'], 'bg=black;fg=white', true);
$output->writeln($blockMessage);
/** @var ProcessHelper $processHelper */
$processHelper = $this->getHelper('process');
$process = ProcessBuilder::create(['figlet', 'Started!'])->getProcess();
$processHelper->run($output, $process, 'Something went wrong');
$finder = new Finder();
$files = $finder->in(CACHE_PATH)->name('makes*json')->files();
$progressHelper = new ProgressBar($output);
$progressHelper->setEmptyBarCharacter('.');
$progressHelper->setBarCharacter('<comment>+</comment>');
if ($input->getOption('progress')) {
$progressHelper->start($files->count());
}
$table = new Table($output);
$table->setStyle('default');
$style = new TableStyle();
$style->setBorderFormat('<comment>%s</comment>');
$table->setStyle($style);
foreach ($files as $file) {
/** @var SplFileInfo $file */
$makes = json_decode($file->getContents(), true);
$table->setHeaders(['Make Name', 'Models Count']);
foreach ($makes['makes'] as $make) {
$table->addRow([$make['name'], count($make['models'])]);
}
// $table->render($output);
if ($input->getOption('progress')) {
$progressHelper->advance();
}
}
if ($input->getOption('progress')) {
$progressHelper->finish();
$output->writeln('');
}
}
开发者ID:GrizliK1988,项目名称:symfony-certification-prepare-project,代码行数:42,代码来源:MakesCacheReportCommand.php
示例13: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$verbosityLevelMap = array(LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL, LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL);
$logger = new ConsoleLogger($output, $verbosityLevelMap);
$progressBar = new ProgressBar($output);
$progressBar->setFormat("<info>[info] %message% : %current%/%max% [</info>%bar%<info>] %percent:3s%% %elapsed:6s%/%estimated:-6s%</info>");
$progressBar->setEmptyBarCharacter('<fg=red>-</>');
$progressBar->setBarCharacter('<info>=</info>');
$progressBar->setProgressCharacter('<info>></info>');
$output->writeln("\n\r<question>Execution de la passerelle JLP-IMMO</question>");
// Appel du service correpondant au CRON
$services = $this->getContainer()->get('jlp_core.passerelle');
$responseServices = $services->execute($logger, $progressBar);
$output->writeln("<info>Passerelle resultat : " . print_r($responseServices, true) . "</info>");
$output->writeln("\n\r");
} catch (\Exception $e) {
$output->writeln("\t<error>Passerelle Exception : " . $e . '</error>');
}
}
示例14: testAnsiColorsAndEmojis
public function testAnsiColorsAndEmojis()
{
$bar = new ProgressBar($output = $this->getOutputStream(), 15);
ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) {
static $i = 0;
$mem = 100000 * $i;
$colors = $i++ ? '41;37' : '44;37';
return "[" . $colors . 'm ' . Helper::formatMemory($mem) . " [0m";
});
$bar->setFormat(" [44;37m %title:-37s% [0m\n %current%/%max% %bar% %percent:3s%%\n 🏁 %remaining:-10s% %memory:37s%");
$bar->setBarCharacter($done = "[32m●[0m");
$bar->setEmptyBarCharacter($empty = "[31m●[0m");
$bar->setProgressCharacter($progress = "[32m➤ [0m");
$bar->setMessage('Starting the demo... fingers crossed', 'title');
$bar->start();
$bar->setMessage('Looks good to me...', 'title');
$bar->advance(4);
$bar->setMessage('Thanks, bye', 'title');
$bar->finish();
rewind($output->getStream());
$this->assertEquals($this->generateOutput(" [44;37m Starting the demo... fingers crossed [0m\n" . ' 0/15 ' . $progress . str_repeat($empty, 26) . " 0%\n" . " 🏁 1 sec [44;37m 0 B [0m") . $this->generateOutput(" [44;37m Looks good to me... [0m\n" . ' 4/15 ' . str_repeat($done, 7) . $progress . str_repeat($empty, 19) . " 26%\n" . " 🏁 1 sec [41;37m 97 KiB [0m") . $this->generateOutput(" [44;37m Thanks, bye [0m\n" . ' 15/15 ' . str_repeat($done, 28) . " 100%\n" . " 🏁 1 sec [41;37m 195 KiB [0m"), stream_get_contents($output->getStream()));
}
示例15: download
/**
* Chooses the best compressed file format to download (ZIP or TGZ) depending upon the
* available operating system uncompressing commands and the enabled PHP extensions
* and it downloads the file.
*
* @throws \RuntimeException if the ProcessWire archive could not be downloaded
*/
private function download()
{
$this->output->writeln("\n Downloading ProcessWire Version " . $this->branch['version'] . "...");
$distill = new Distill();
$pwArchiveFile = $distill->getChooser()->setStrategy(new MinimumSize())->addFile($this->branch['zipURL'])->getPreferredFile();
/** @var ProgressBar|null $progressBar */
$progressBar = null;
$downloadCallback = function ($size, $downloaded, $client, $request, Response $response) use(&$progressBar) {
// Don't initialize the progress bar for redirects as the size is much smaller
if ($response->getStatusCode() >= 300) {
return;
}
if (null === $progressBar) {
ProgressBar::setPlaceholderFormatterDefinition('max', function (ProgressBar $bar) {
return $this->formatSize($bar->getMaxSteps());
});
ProgressBar::setPlaceholderFormatterDefinition('current', function (ProgressBar $bar) {
return str_pad($this->formatSize($bar->getStep()), 11, ' ', STR_PAD_LEFT);
});
$progressBar = new ProgressBar($this->output, $size);
$progressBar->setFormat('%current%/%max% %bar% %percent:3s%%');
$progressBar->setRedrawFrequency(max(1, floor($size / 1000)));
$progressBar->setBarWidth(60);
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$progressBar->setEmptyBarCharacter('░');
// light shade character \u2591
$progressBar->setProgressCharacter('');
$progressBar->setBarCharacter('▓');
// dark shade character \u2593
}
$progressBar->start();
}
$progressBar->setProgress($downloaded);
};
$client = new Client();
$client->getEmitter()->attach(new Progress(null, $downloadCallback));
// store the file in a temporary hidden directory with a random name
$this->compressedFilePath = getcwd() . DIRECTORY_SEPARATOR . '.' . uniqid(time()) . DIRECTORY_SEPARATOR . 'pw.' . pathinfo($pwArchiveFile, PATHINFO_EXTENSION);
try {
$response = $client->get($pwArchiveFile);
} catch (ClientException $e) {
if ($e->getCode() === 403 || $e->getCode() === 404) {
throw new \RuntimeException(sprintf("The selected version (%s) cannot be installed because it does not exist.\n" . "Try the special \"latest\" version to install the latest stable ProcessWire release:\n" . '%s %s %s latest', $this->version, $_SERVER['PHP_SELF'], $this->getName(), $this->projectDir));
} else {
throw new \RuntimeException(sprintf("The selected version (%s) couldn't be downloaded because of the following error:\n%s", $this->version, $e->getMessage()));
}
}
$this->fs->dumpFile($this->compressedFilePath, $response->getBody());
if (null !== $progressBar) {
$progressBar->finish();
$this->output->writeln("\n");
}
return $this;
}