当前位置: 首页>>代码示例>>PHP>>正文


PHP ProgressBar::setBarWidth方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::setBarWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::setBarWidth方法的具体用法?PHP ProgressBar::setBarWidth怎么用?PHP ProgressBar::setBarWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Helper\ProgressBar的用法示例。


在下文中一共展示了ProgressBar::setBarWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __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

示例2: 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;
 }
开发者ID:spryker,项目名称:Gui,代码行数:17,代码来源:ProgressBarBuilder.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $shopId = $input->getArgument('shopId');
     if (!empty($shopId)) {
         $shopIds[] = $shopId;
     } else {
         $shopIds = $this->container->get('db')->fetchCol('SELECT id FROM s_core_shops WHERE active = 1');
     }
     /** @var \Shopware\Components\HttpCache\CacheWarmer $cacheWarmer */
     $cacheWarmer = $this->container->get('http_cache_warmer');
     foreach ($shopIds as $shopId) {
         $limit = 10;
         $offset = 0;
         $totalUrlCount = $cacheWarmer->getAllSEOUrlCount($shopId);
         $output->writeln("\n Calling URLs for shop with id " . $shopId);
         $progressBar = new ProgressBar($output, $totalUrlCount);
         $progressBar->setBarWidth(100);
         $progressBar->start();
         while ($offset < $totalUrlCount) {
             $urls = $cacheWarmer->getAllSEOUrls($shopId, $limit, $offset);
             $cacheWarmer->callUrls($urls, $shopId);
             $progressBar->advance(count($urls));
             $offset += count($urls);
         }
         $progressBar->finish();
     }
     $output->writeln("\n The HttpCache is now warmed up");
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:31,代码来源:WarmUpHttpCacheCommand.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $startTime = microtime(true);
     $output->writeln("phplint {$this->getApplication()->getVersion()}");
     $output->writeln('');
     $phpBinary = PHP_BINARY;
     $path = $input->getArgument('path');
     $exclude = $input->getOption('exclude');
     $extensions = $input->getOption('extensions');
     $procLimit = $input->getOption('jobs');
     // $failOnFirst = $input->getOption('fail-on-first');
     if ($extensions) {
         $extensions = explode(',', $extensions);
     } else {
         $extensions = array('php');
     }
     $linter = new Linter($path, $exclude, $extensions);
     if ($procLimit) {
         $linter->setProcessLimit($procLimit);
     }
     $files = $linter->getFiles();
     $fileCount = count($files);
     $progress = new ProgressBar($output, $fileCount);
     $progress->setBarWidth(50);
     $progress->setMessage('', 'overview');
     $progress->setFormat(" %overview%\n %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%");
     $progress->start();
     $linter->setProcessCallback(function ($status, $filename) use($progress) {
         /*
         $overview = $progress->getMessage('overview');
         
         if ($status == 'ok') {
             $overview .= '.';
         } elseif ($status == 'error') {
             $overview .= 'F';
             // exit(1);
         }
         
         $progress->setMessage($overview, 'overview');
         */
         $progress->advance();
     });
     $result = $linter->lint($files);
     $progress->finish();
     $output->writeln('');
     $testTime = microtime(true) - $startTime;
     $code = 0;
     $errCount = count($result);
     $out = "<info>Checked {$fileCount} files in " . round($testTime, 1) . " seconds</info>";
     if ($errCount > 0) {
         $out .= "<info> and found syntax errors in </info><error>{$errCount}</error><info> files.</info>";
         $out .= "\n" . json_encode($result, JSON_PRETTY_PRINT);
         $code = 1;
     } else {
         $out .= '<info> a no syntax error were deteced.';
     }
     $output->writeln($out . PHP_EOL);
     return $code;
 }
开发者ID:watsonad,项目名称:opendocman,代码行数:59,代码来源:LintCommand.php

示例5: 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;
 }
开发者ID:skymeyer,项目名称:sugardev,代码行数:10,代码来源:ProgressBarFactory.php

示例6: 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;
 }
开发者ID:lexcast,项目名称:fminor-core,代码行数:15,代码来源:BuildCommand.php

示例7: testCustomizations

 public function testCustomizations()
 {
     $bar = new ProgressBar($output = $this->getOutputStream(), 10);
     $bar->setBarWidth(10);
     $bar->setBarCharacter('_');
     $bar->setEmptyBarCharacter(' ');
     $bar->setProgressCharacter('/');
     $bar->setFormat(' %current%/%max% [%bar%] %percent:3s%%');
     $bar->start();
     $bar->advance();
     rewind($output->getStream());
     $this->assertEquals($this->generateOutput('  0/10 [/         ]   0%') . $this->generateOutput('  1/10 [_/        ]  10%'), stream_get_contents($output->getStream()));
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:13,代码来源:ProgressBarTest.php

示例8: createStreamContext

 /**
  * @param OutputInterface $output
  *
  * @return resource
  */
 protected function createStreamContext(OutputInterface $output)
 {
     $ctx = stream_context_create([], ['notification' => function ($code, $severity, $message, $message_code, $bytesTransferred, $bytesMax) use($output) {
         switch ($code) {
             case STREAM_NOTIFY_FILE_SIZE_IS:
                 $this->progress = new ProgressBar($output, $bytesMax);
                 $this->progress->setBarWidth(75);
                 $this->progress->start();
                 break;
             case STREAM_NOTIFY_PROGRESS:
                 $this->progress->setCurrent($bytesTransferred);
                 if ($bytesTransferred == $bytesMax) {
                     $this->progress->finish();
                     $output->writeln('');
                 }
                 break;
             case STREAM_NOTIFY_COMPLETED:
                 $this->progress->finish();
                 break;
         }
     }]);
     return $ctx;
 }
开发者ID:shakaran,项目名称:forge-cli,代码行数:28,代码来源:SelfUpdateCommand.php

示例9: __construct

 public function __construct(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('no-progress-bar')) {
         $progressBar = new ProgressBar($output);
         $progressBar->setFormat('verbose');
         $progressBar->setBarWidth(58);
         if (!$output->isDecorated()) {
             $progressBar->setRedrawFrequency(60);
         }
         $this->progressBar = $progressBar;
     } else {
         $this->isDisabled = true;
     }
 }
开发者ID:shadowhand,项目名称:humbug,代码行数:14,代码来源:ProgressBarObserver.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rows = 100;
     $progressBar = new ProgressBar($output, $rows);
     $progressBar->setBarCharacter('<comment>=</comment>');
     $progressBar->setProgressCharacter('>');
     $progressBar->setBarWidth(77);
     $table = new Table($output);
     for ($i = 0; $i < $rows; $i++) {
         $table->addRow([sprintf('Row <info># %s</info>', $i), rand(0, 1000)]);
         usleep(50000);
         $progressBar->advance();
     }
     $progressBar->finish();
     $output->writeln('');
     $table->render();
 }
开发者ID:SymfonyId,项目名称:PlaySymfony,代码行数:17,代码来源:TableCommand.php

示例11: 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;
 }
开发者ID:gushphp,项目名称:gush,代码行数:51,代码来源:DownloadHelper.php

示例12: 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();
     }
 }
开发者ID:MrAdder,项目名称:phpbb,代码行数:22,代码来源:cli_iohandler.php

示例13: createProgressBar

 /**
  * @param OutputInterface $output
  * @param int             $statementCount
  *
  * @return ProgressBar
  */
 private function createProgressBar(OutputInterface $output, int $statementCount) : ProgressBar
 {
     $progress = new ProgressBar($output);
     $progress->setRedrawFrequency(1);
     $progress->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% %message%');
     $progress->setMessage('<info>starting</info>');
     $progress->start($statementCount);
     $progress->setBarWidth(min(4 * $statementCount + 2, 50));
     return $progress;
 }
开发者ID:yapeal,项目名称:yapeal-ng,代码行数:16,代码来源:AbstractSchemaCommon.php

示例14: 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;
 }
开发者ID:samuell,项目名称:wireshell,代码行数:61,代码来源:UpgradeCommand.php

示例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.
  *
  * @return $this
  *
  * @throws \RuntimeException If the Symfony archive could not be downloaded
  */
 protected function download()
 {
     $this->output->writeln(sprintf("\n Downloading %s...\n", $this->getDownloadedApplicationType()));
     // decide which is the best compressed version to download
     $distill = new Distill();
     $symfonyArchiveFile = $distill->getChooser()->setStrategy(new MinimumSize())->addFilesWithDifferentExtensions($this->getRemoteFileUrl(), ['tgz', 'zip'])->getPreferredFile();
     /** @var ProgressBar|null $progressBar */
     $progressBar = null;
     $downloadCallback = function (ProgressEvent $event) use(&$progressBar) {
         $downloadSize = $event->downloadSize;
         $downloaded = $event->downloaded;
         // progress bar is only displayed for files larger than 1MB
         if ($downloadSize < 1 * 1024 * 1024) {
             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, $downloadSize);
             $progressBar->setFormat('%current%/%max% %bar%  %percent:3s%%');
             $progressBar->setRedrawFrequency(max(1, floor($downloadSize / 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();
     // store the file in a temporary hidden directory with a random name
     $this->downloadedFilePath = rtrim(getcwd(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '.' . uniqid(time()) . DIRECTORY_SEPARATOR . 'symfony.' . pathinfo($symfonyArchiveFile, PATHINFO_EXTENSION);
     try {
         $request = $client->createRequest('GET', $symfonyArchiveFile);
         $request->getEmitter()->on('progress', $downloadCallback);
         $response = $client->send($request);
     } catch (ClientException $e) {
         if ('new' === $this->getName() && ($e->getCode() === 403 || $e->getCode() === 404)) {
             throw new \RuntimeException(sprintf("The selected version (%s) cannot be installed because it does not exist.\n" . "Execute the following command to install the latest stable Symfony release:\n" . '%s new %s', $this->version, $_SERVER['PHP_SELF'], str_replace(getcwd() . DIRECTORY_SEPARATOR, '', $this->projectDir)));
         } else {
             throw new \RuntimeException(sprintf("There was an error downloading %s from symfony.com server:\n%s", $this->getDownloadedApplicationType(), $e->getMessage()), null, $e);
         }
     }
     $this->fs->dumpFile($this->downloadedFilePath, $response->getBody());
     if (null !== $progressBar) {
         $progressBar->finish();
         $this->output->writeln("\n");
     }
     return $this;
 }
开发者ID:smatyas,项目名称:symfony-installer,代码行数:67,代码来源:DownloadCommand.php


注:本文中的Symfony\Component\Console\Helper\ProgressBar::setBarWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。