本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::start方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::start方法的具体用法?PHP ProgressBar::start怎么用?PHP ProgressBar::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
protected function test($count, $classes, OutputInterface $output)
{
$this->table = new Table($output);
$this->table->setHeaders(array('Implementation', 'Memory', 'Duration'));
$output->writeln(sprintf('<info>%d elements</info>', $count));
$this->process = new ProgressBar($output, count($classes));
$this->process->start();
foreach ($classes as $class) {
$shortClass = $class;
// if (in_array($class, $blacklist)) {
// $this->table->addRow([$class, '--', '--']);
// continue;
// };
$path = __DIR__ . '/../../bin/test.php';
$result = `php {$path} {$class} {$count}`;
$data = json_decode($result, true);
if (!$data) {
echo $result;
}
$this->table->addRow([$shortClass, sprintf('%11sb', number_format($data['memory'])), sprintf('%6.4fs', $data['time'])]);
$this->process->advance();
}
$this->process->finish();
$output->writeln('');
$this->table->render($output);
}
示例2: prepare
/**
* {@inheritdoc}
*/
public function prepare()
{
$this->progress = new ProgressBar($this->output, $this->reader->count());
$this->progress->setFormat($this->verbosity);
$this->progress->setRedrawFrequency($this->redrawFrequency);
$this->progress->start();
}
示例3: start
/**
* {@inheritdoc}
*/
public function start()
{
$dispatcher = $this->getDispatcher();
$sourceEvent = new SourcePipelineEvent();
$sourceEvent->setContext($this->getContext());
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_SOURCE), $sourceEvent);
$this->setContext($sourceEvent->getContext());
$sources = $sourceEvent->getSources();
$outputs = [];
$startEvent = new StartPipelineEvent();
$startEvent->setContext($this->getContext());
$startEvent->setItemCount($this->countSourceItems($sources));
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_START), $startEvent);
$this->setContext($startEvent->getContext());
$this->progressBar && $this->progressBar->start($this->countSourceItems($sources));
foreach ($sources as $source) {
foreach ($source as $item) {
$itemEvent = new ItemPipelineEvent($item);
$itemEvent->setContext($this->getContext());
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_MODIFY), $itemEvent);
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_CONSUME), $itemEvent);
$output = $itemEvent->getOutput();
if ($output !== null) {
$outputs[] = $output;
}
$this->setContext($itemEvent->getContext());
$this->progressBar && $this->progressBar->advance();
}
}
$finishEvent = new FinishPipelineEvent();
$finishEvent->setContext($this->getContext());
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_FINISH), $finishEvent);
$this->progressBar && $this->progressBar->finish();
return ['outputs' => $outputs];
}
示例4: run
public function run(OutputInterface $output)
{
$output->writeln('**********************************');
$output->writeln('Starting sync for dojos');
$this->progressBar = $this->newProgressBar($output);
$externalDojos = $this->zen->getDojos();
$this->progressBar->start(count($externalDojos));
$this->progressBar->setMessage('Iterating dojos...');
foreach ($externalDojos as $externalDojo) {
$this->progressBar->setMessage('Handling ' . $externalDojo->getName());
if (true === $externalDojo->isRemoved()) {
$this->removeInternalDojo($externalDojo);
continue;
}
try {
$internalDojo = $this->getInternalDojo($externalDojo->getZenId(), $externalDojo->getCity(), $externalDojo->getTwitter(), $externalDojo->getEmail());
} catch (NonUniqueResultException $exception) {
$this->unmatched[] = $externalDojo;
continue;
}
if (null !== $internalDojo) {
$this->updateInternalDojo($internalDojo, $externalDojo);
continue;
}
$this->createDojo($externalDojo);
}
$this->progressBar->setMessage('Flushing');
$this->doctrine->flush();
$this->progressBar->setMessage('Finished syncing dojos!');
$this->progressBar->finish();
$output->writeln($this->countNew . ' New dojos added');
$output->writeln($this->countUpdated . ' Existing dojos updated');
$output->writeln($this->countRemoved . ' Existing dojos removed');
$this->notifySlack();
}
示例5: startProgress
/**
* @param RunnerEvent $event
*/
public function startProgress(RunnerEvent $event)
{
$numberOftasks = $event->getTasks()->count();
$this->progressBar->setFormat('<fg=yellow>%message%</fg=yellow>');
$this->progressBar->setMessage('GrumPHP is sniffing your code!');
$this->progressBar->start($numberOftasks);
}
示例6: setupProgressBar
/**
* @param OutputInterface $output
* @param Repository $source
* @param WritableRepository $destination
*/
private function setupProgressBar(OutputInterface $output, Repository $source, WritableRepository $destination)
{
$this->progress = new ProgressBar($output, count($source));
$this->progress->setMessage('Generating database...');
$this->progress->start();
$destination->attach($this);
}
示例7: start
/**
* Starting the install process.
*
* @param string $message Start message
* @param int $maxSteps The number of steps that will be taken
*/
public function start($message, $maxSteps)
{
$this->info($message);
if ($this->progressBar instanceof ProgressBar) {
$this->progressBar->setMessage($message);
$this->progressBar->start($maxSteps);
}
}
示例8: progressBarInit
private function progressBarInit($count)
{
if ($this->progressBar === null) {
return;
}
$this->progressBar->start($count);
$this->progressBar->setBarCharacter(Constants::CHARACTER_PROGRESS_BAR);
$this->progressBar->setProgressCharacter(Constants::CHARACTER_BEER);
}
示例9: startProgress
protected function startProgress($num = 2)
{
if (!$this->getOutput()) {
throw new \Exception('Unable to find console output object.');
}
$this->bar = new ProgressBar($this->getOutput(), $num);
$this->bar->setFormat("%message%\n [%bar%] %percent:3s%% %elapsed% %memory:6s% ");
$this->bar->start();
}
示例10: start
/**
* @param int $total
*/
public function start($total)
{
if (!$this->verbose) {
return;
}
$format = $this->label . ': <comment>loading %max% files into memory, this can take some time</comment>';
$this->progressBar->setFormat($format);
$this->progressBar->start($total);
}
示例11: onPreFetch
/**
* @param TransportEvent $event
*/
public function onPreFetch(TransportEvent $event)
{
$size = $event->getTransport()->getSize();
if ($event->getTransport() instanceof ProgressAwareInterface && $size > 0) {
$this->progress->start($size);
$this->progressActive = true;
}
$this->progress->setMessage(sprintf('Downloading <info>%s</info> (%s KB)', (string) $event->getTransport(), $size > 0 ? number_format(round($size / 1024), 0, ',', '.') : 'unknown'));
}
示例12: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$config = Config::getInstance();
$noProgress = $input->getOption('no-progress');
$query = $input->getArgument('query');
$provider = $config->getQuery($query);
if (empty($provider)) {
$output->writeln("<error>cannot found query \"{$query}\"</error>");
$output->writeln("<info>you can execute \"</info>ipv4 edit<info>\" to configure the query</info>");
return 1;
}
$type = $input->getOption('type');
$filename = $config->getFilename($input->getArgument('filename'));
$export = ExportQuery::create($type, $filename);
if (empty($export)) {
$output->writeln("<error>cannot found export query \"{$type}\"</error>");
return 2;
}
$export->setProviders([$provider]);
$encoding = $input->getOption('encoding');
if (!empty($encoding)) {
$export->setEncoding($encoding);
}
$ecdz = $input->getOption('ecdz');
if ($ecdz && method_exists($export, 'setEcdz')) {
$export->setEcdz($ecdz);
}
$remove_ip_in_recode = $input->getOption('remove-ip-in-recode');
if ($remove_ip_in_recode && method_exists($export, 'setRemoveIpInRecode')) {
$export->setRemoveIpInRecode($remove_ip_in_recode);
}
$output->writeln("<info>export \"{$query}\" to \"{$type}\" filename \"{$filename}\":</info>");
if (!$noProgress) {
$export->init(function ($code, $n) use($output) {
switch ($code) {
case 0:
$this->progress = new ProgressBar($output, $n);
$this->progress->start();
break;
case 1:
$this->progress->setProgress($n);
break;
case 2:
$this->progress->finish();
break;
}
});
} else {
$export->init();
}
$output->writeln('<info> completed!</info>');
return 0;
}
示例13: __invoke
/**
* @param string $type
* @param string $buffer
*/
public function __invoke(string $type, string $buffer)
{
if ($type === 'err' && preg_match('/^-n\\s*\\d+\\s*\\/\\s*(\\d+)\\s*\\((\\d+)\\)\\s*$/', $buffer, $matches)) {
if ($this->progressBar === null) {
$this->progressBar = new ProgressBar($this->output, (int) $matches[1]);
$this->progressBar->setBarWidth(100);
$this->progressBar->start();
}
$this->progressBar->advance();
$this->updates = $matches[2];
}
}
示例14: setDownloadWithProgressBar
private function setDownloadWithProgressBar()
{
$emitter = $this->httpClient->getEmitter();
$emitter->on('before', function (\GuzzleHttp\Event\BeforeEvent $event) {
echo $event->getRequest();
});
$emitter->once('progress', function (\GuzzleHttp\Event\ProgressEvent $event) {
$this->progressBar->start($event->downloadSize);
});
$emitter->on('progress', function (\GuzzleHttp\Event\ProgressEvent $event) {
$this->progressBar->setProgress($event->downloaded);
});
}
示例15: invoke
public function invoke(ElasticPopulator $populator)
{
$begin = function ($total) {
$this->bar = new ProgressBar($this->out, $total);
$this->bar->start();
};
$tick = function () {
$this->bar->advance();
};
$rows = $populator->populate($begin, $tick);
$this->bar->finish();
$this->out->write("\n");
$this->out->writeln("<info>Reindexed {$rows} rows</info>");
}