PHPackages                             nickbeen/php-cli-progress-bar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. nickbeen/php-cli-progress-bar

ActiveLibrary[CLI &amp; Console](/categories/cli)

nickbeen/php-cli-progress-bar
=============================

For creating minimal progress bars in PHP CLI scripts

1.2.0(9mo ago)247.3k↓66.3%2MITPHPPHP ^8.0CI passing

Since Jun 17Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/nickbeen/php-cli-progress-bar)[ Packagist](https://packagist.org/packages/nickbeen/php-cli-progress-bar)[ Docs](https://github.com/nickbeen/php-cli-progress-bar)[ RSS](/packages/nickbeen-php-cli-progress-bar/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

PHP CLI Progress Bar
====================

[](#php-cli-progress-bar)

[![Latest version](https://camo.githubusercontent.com/37573fe6e5578531c587c33efd9cf8b5775b2c67d5132a71016aad7e4455dc8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e69636b6265656e2f7068702d636c692d70726f67726573732d626172)](https://packagist.org/packages/nickbeen/php-cli-progress-bar)[![Build status](https://camo.githubusercontent.com/295a80462dfe822ea1c46942e1de022141855cc3b593de840ccf1373969c0b75/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e69636b6265656e2f7068702d636c692d70726f67726573732d6261722f72756e2d74657374732e796d6c)](https://packagist.org/packages/nickbeen/php-cli-progress-bar)[![Total downloads](https://camo.githubusercontent.com/65c156684e2edfc57a53c9ea97b3b3499803f1a75553980430a6c447d1b64528/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e69636b6265656e2f7068702d636c692d70726f67726573732d626172)](https://packagist.org/packages/nickbeen/php-cli-progress-bar)[![PHP Version](https://camo.githubusercontent.com/5f0c66875cc67e8933fa2ba741037b85b510d5913837d11ce53293e21c244561/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e69636b6265656e2f7068702d636c692d70726f67726573732d626172)](https://packagist.org/packages/nickbeen/php-cli-progress-bar)[![License](https://camo.githubusercontent.com/75d745cb993f436cc6aff507c1880444acd6903c53a38e7a4a0ee6a39e6ab7af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e69636b6265656e2f7068702d636c692d70726f67726573732d626172)](https://packagist.org/packages/nickbeen/php-cli-progress-bar)

For creating minimal progress bars in PHP CLI scripts. It has no dependencies, but requires PHP 8.0 or higher. This library is mainly built for iterating to countable variables, but also works easily with ticking through less structured step-by-step scripts.

Many PHP CLI progress bars have been written in the past, but most haven't been updated in years. This library uses the latest PHP features such as return types, named arguments and constructor property promotions. For creating richer, more customizable progress bars, check alternatives such as the progress bar helper included in the [symfony/console](https://symfony.com/doc/current/components/console/helpers/progressbar.html) package.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher

Installation
------------

[](#installation)

Install the library into your project with Composer.

```
composer require nickbeen/php-cli-progress-bar

```

Usage
-----

[](#usage)

With this library you can display a progress bar in a PHP CLI script to indicate the script is doing its work and how far it has progressed. All you need to do is start displaying the progress bar, tick through the steps the script goes through and finish the display of the progress bar.

```
  1/100 [#...........................]   1% (00:00:16)

```

```
 64/100 [##################..........]  64% (00:00:07)

```

```
100/100 [############################] 100%

```

### Manually progressing

[](#manually-progressing)

It is possible to tick through the steps of your scripts manually when the steps in your script cannot be looped. Each tick adds one progression, but you can override the progression made by including an integer in `tick()`.

You do need to set `maxProgress` for the progress bar to display the correct numbers by including it in the constructor. If you don't know the maxProgress during initialization, you can set it later with the `setMaxProgress()` method.

```
$progressBar = new \NickBeen\ProgressBar\ProgressBar(maxProgress: 62);
$progressBar->start();

doSomething();
$progressBar->tick();

doSomethingElse();
$progressBar->tick();

doSixtyTasks();
$progressBar->tick(60);

$progressBar->finish();
```

If you have a little more structure in your step-by-step code, you can easily place `tick()` in a for loop. There is however a more convenient method when dealing with e.g. arrays.

### Iterating through arrays or traversable instances

[](#iterating-through-arrays-or-traversable-instances)

This class method works with anything of the pseudo-type [iterable](https://www.php.net/manual/en/language.types.iterable.php) which includes any array or any instance of [Traversable](https://www.php.net/manual/en/class.traversable.php). The `iterate()` method automatically handles starting the progress bar, managing ticking through the iteration and finally finish displaying the progress bar.

```
$array = [
    1 => 'A',
    2 => 'B',
    3 => 'C',
];

$progressBar = new \NickBeen\ProgressBar\ProgressBar();

foreach ($progressBar->iterate($array) as $key => $value) {
    echo "$key: $value" . PHP_EOL;
}
```

### Interact with the progress bar

[](#interact-with-the-progress-bar)

It is possible to interact with the progress bar during its run. You can retrieve the estimated time to finish, the progress it has made, the maximum progress that has been set and the amount of completion in percentage. You can use this information e.g. for notifications or other tasks in the background.

```
foreach ($progressBar->iterate($array);) {
    // Some custom notification
    sendToDiscord($progressBar->getEstimatedTime());

    // Some custom task application
    syncWithCloud($progressBar->getPercentage())

    // Some other custom application
    sendToRaspberryPiDisplay($progressBar->getProgress(), $progressBar->getMaxProgress())
}
```

License
-------

[](#license)

This library is licensed under the MIT License (MIT). See the [LICENSE](LICENSE.md) for more details.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance62

Regular maintenance activity

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~232 days

Recently: every ~290 days

Total

6

Last Release

290d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/66799549?v=4)[Nick Been](/maintainers/nickbeen)[@nickbeen](https://github.com/nickbeen)

---

Top Contributors

[![nickbeen](https://avatars.githubusercontent.com/u/66799549?v=4)](https://github.com/nickbeen "nickbeen (38 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![fulldecent](https://avatars.githubusercontent.com/u/382183?v=4)](https://github.com/fulldecent "fulldecent (1 commits)")[![thisispiers](https://avatars.githubusercontent.com/u/1831251?v=4)](https://github.com/thisispiers "thisispiers (1 commits)")

---

Tags

cliphpprogress-barphpcliprogress bar

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nickbeen-php-cli-progress-bar/health.svg)

```
[![Health](https://phpackages.com/badges/nickbeen-php-cli-progress-bar/health.svg)](https://phpackages.com/packages/nickbeen-php-cli-progress-bar)
```

###  Alternatives

[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k260.6M359](/packages/nunomaduro-termwind)[nunomaduro/laravel-console-task

Laravel Console Task is a output method for your Laravel/Laravel Zero commands.

2582.3M13](/packages/nunomaduro-laravel-console-task)[mehrancodes/laravel-harbor

A CLI tool to Quickly create On-Demand preview environment for your apps.

10095.6k](/packages/mehrancodes-laravel-harbor)[php-school/learn-you-php

An introduction to PHP's core features: i/o, http, arrays, exceptions and so on.

3202.0k](/packages/php-school-learn-you-php)[alecrabbit/php-cli-snake

Lightweight cli spinner with zero dependencies

29214.4k5](/packages/alecrabbit-php-cli-snake)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
