當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ProgressBar::start方法代碼示例

本文整理匯總了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);
 }
開發者ID:Pandahisham,項目名稱:topsort.php,代碼行數:26,代碼來源:BenchmarkCommand.php

示例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();
 }
開發者ID:megamanhxh,項目名稱:data-import,代碼行數:10,代碼來源:ConsoleProgressWriter.php

示例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];
 }
開發者ID:asev,項目名稱:ConnectionsBundle,代碼行數:38,代碼來源:Pipeline.php

示例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();
 }
開發者ID:CoderDojoNederland,項目名稱:Website,代碼行數:35,代碼來源:SyncDojoService.php

示例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);
 }
開發者ID:phpro,項目名稱:grumphp,代碼行數:10,代碼來源:ProgressSubscriber.php

示例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);
 }
開發者ID:nick-jones,項目名稱:php-ucd,代碼行數:12,代碼來源:RepositoryTransferCommand.php

示例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);
     }
 }
開發者ID:gjb2048,項目名稱:moodle-plugin-ci,代碼行數:14,代碼來源:InstallOutput.php

示例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);
 }
開發者ID:bitban,項目名稱:php-code-quality-tools,代碼行數:9,代碼來源:HookManager.php

示例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();
 }
開發者ID:humweb,項目名稱:slackpipe,代碼行數:9,代碼來源:ProgressbarTrait.php

示例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);
 }
開發者ID:Soullivaneuh,項目名稱:deprecation-detector,代碼行數:12,代碼來源:VerboseProgressOutput.php

示例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'));
 }
開發者ID:treehouselabs,項目名稱:io-bundle,代碼行數:12,代碼來源:ImportOutputSubscriber.php

示例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;
 }
開發者ID:larryli,項目名稱:ipv4-console,代碼行數:58,代碼來源:ExportCommand.php

示例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];
     }
 }
開發者ID:gplanchat,項目名稱:grenade,代碼行數:16,代碼來源:GitSubtreeProgressBarHelper.php

示例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);
     });
 }
開發者ID:fonsecas72,項目名稱:selenium-handler,代碼行數:13,代碼來源:SeleniumDownloader.php

示例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>");
 }
開發者ID:VasekPurchart,項目名稱:khanovaskola-v3,代碼行數:14,代碼來源:Populate.php


注:本文中的Symfony\Component\Console\Helper\ProgressBar::start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。