@@ -278,77 +278,6 @@ You can combine VALUE_IS_ARRAY with VALUE_REQUIRED or VALUE_OPTIONAL like this:
278
278
1
279
279
);
280
280
281
- Displaying a Progress Bar
282
- -------------------------
283
-
284
- .. versionadded :: 2.2
285
- The ``progress `` helper was added in Symfony 2.2.
286
-
287
- When executing longer-running commands, it may be helpful to show progress
288
- information, which updates as your command runs:
289
-
290
- .. image :: /images/components/console/progress.png
291
-
292
- To display progress details, use the :class: `Symfony\\ Component\\ Console\\ Helper\\ ProgressHelper `,
293
- pass it a total number of units, and advance the progress as your command executes::
294
-
295
- $progress = $this->getHelperSet()->get('progress');
296
-
297
- $progress->start($output, 50);
298
- $i = 0;
299
- while ($i++ < 50) {
300
- // do some work
301
-
302
- // advance the progress bar 1 unit
303
- $progress->advance();
304
- }
305
-
306
- $progress->finish();
307
-
308
- The appearance of the progress output can be customized as well, with a number
309
- of different levels of verbosity. Each of these displays different possible
310
- items - like percentage completion, a moving progress bar, or current/total
311
- information (e.g. 10/50)::
312
-
313
- $progress->setFormat(ProgressHelper::FORMAT_QUIET);
314
- $progress->setFormat(ProgressHelper::FORMAT_NORMAL);
315
- $progress->setFormat(ProgressHelper::FORMAT_VERBOSE);
316
- $progress->setFormat(ProgressHelper::FORMAT_QUIET_NOMAX);
317
- // the default value
318
- $progress->setFormat(ProgressHelper::FORMAT_NORMAL_NOMAX);
319
- $progress->setFormat(ProgressHelper::FORMAT_VERBOSE_NOMAX);
320
-
321
- You can also control the different characters and the width used for the
322
- progress bar::
323
-
324
- // the finished part of the bar
325
- $progress->setBarCharacter('<comment>=</comment>');
326
- // the unfinished part of the bar
327
- $progress->setEmptyBarCharacter(' ');
328
- $progress->setProgressCharacter('|');
329
- $progress->setBarWidth(50);
330
-
331
- To see other available options, check the API documentation for
332
- :class: `Symfony\\ Component\\ Console\\ Helper\\ ProgressHelper `.
333
-
334
- .. caution ::
335
-
336
- For performance reasons, be careful to not set the total number of steps
337
- to a high number. For example, if you're iterating over a large number
338
- of items, consider a smaller "step" number that updates on only some
339
- iterations::
340
-
341
- $progress->start($output, 500);
342
- $i = 0;
343
- while ($i++ < 50000) {
344
- // ... do some work
345
-
346
- // advance every 100 iterations
347
- if ($i % 100 == 0) {
348
- $progress->advance();
349
- }
350
- }
351
-
352
281
Console Helpers
353
282
---------------
354
283
@@ -357,6 +286,7 @@ tools capable of helping you with different tasks:
357
286
358
287
* :doc: `/components/console/helpers/dialoghelper `: interactively ask the user for information
359
288
* :doc: `/components/console/helpers/formatterhelper `: customize the output colorization
289
+ * :doc: `/components/console/helpers/progresshelper `: shows a progress bar
360
290
361
291
Testing Commands
362
292
----------------
0 commit comments