PHPackages                             stilliard/generic-loading-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. stilliard/generic-loading-bar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stilliard/generic-loading-bar
=============================

Generic loading bar PHP component

1.0.0(2y ago)02MIT

Since Dec 20Compare

[ Source](https://github.com/stilliard/generic-loading-bar)[ Packagist](https://packagist.org/packages/stilliard/generic-loading-bar)[ RSS](/packages/stilliard-generic-loading-bar/feed)WikiDiscussions Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Generic Loading Bar
===================

[](#generic-loading-bar)

A generic PHP loader/progress bar utility package to help with applications that need to display a loading bar during a long running process.

Install with composer:

```
composer require stilliard/generic-loading-bar
```

Basic usage
-----------

[](#basic-usage)

```
use GLB\LoadingBar;
$loading = new LoadingBar;
$loading->step(); // each call is 1/100 (or whatever steps is set to)
$loading->set(40); // set a specific loaded %
$loading->complete(); // sets to 100 to mark as complete
$loading->reset(); // sets to 0 to start over
```

or with options:

```
$loading = new LoadingBar([
    'codename' => 'my_loading_bar',
    'min' => 0,
    'max' => 100,
    'steps' => 150, // default: 100
    'dataHandler' => DBDataHandler::class, // default ProcessDataHandler
    'displayHandler' => HTMLDisplayHandler::class, // default EchoDisplayHandler
]);
```

```
$loading->step(); // each call is then 1/150 (or whatever steps is set to)
```

### Display the loading bar

[](#display-the-loading-bar)

```
echo $loading->display(); // displays the html loading bar with auto refresh
```

or

```
echo $loading; // same as above
```

### Ranged loading calculations

[](#ranged-loading-calculations)

Ranged calculations are the original reason for this package. Want to split your loading into 4 parts, each with 25% but then have maybe thousands of records to process inside? This handles this for you.

```
$totalProducts = count($products);
foreach ($products as $i => $product) {
    // fill in the range between 25% to 50% as the % of the total products handled so far. [index, total]
    $loading->calc([25, 50], [$i + 1, $totalProducts]);
}
```

### Demo

[](#demo)

Check out the `demo` folder for a basic CLI demo in `cli.php`, or a full web and background process demo using the Redis data handler in the `html` folder, there's a [`README.md`](https://github.com/stilliard/generic-loading-bar/tree/main/demo/html) file in there with more information.

### Data Handlers

[](#data-handlers)

- **Process** `ProcessDataHandler` runs just in process and doesn't save anywhere
- **Redis** `RedisDataHandler` uses redis to store the current loading %
- **PDO** `PDODataHandler` uses a database with a PDO instance, lets you pass a DB PDO instance/object in via the construct options to then query an assumed `loading_bars` table with `name` and `value` columns.
- **DB** `DBDataHandler` like above PDO one but instead of passing a `pdo` instance, it assumes you have a `DB` global class

Build your own by extending the abstract `BaseDataHandler` class, see how the above ones work as an example in the `src/DataHandler` folders.

### Display Handlers

[](#display-handlers)

- **Echo** `EchoDisplayHandler` simply echos/outputs the current % at the point of `->display()` called
- **Console** `ConsoleDisplayHandler` a CLI/Console ascii loading/progress bar e.g. `[===>    ] 50%`
- **HTML** `HTMLDisplayHandler` shows a `` element at point of display, could then be auto refreshed from there through ajax

Build your own by extending the abstract `BaseDisplayHandler` class, see how the above ones work as an example in the `src/DisplayHandler` folders.

### License

[](#license)

This project is open-sourced software licensed under the [MIT license](https://opensource.org/license/mit/).

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

926d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77454?v=4)[Andrew Stilliard](/maintainers/stilliard)[@stilliard](https://github.com/stilliard)

---

Top Contributors

[![stilliard](https://avatars.githubusercontent.com/u/77454?v=4)](https://github.com/stilliard "stilliard (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stilliard-generic-loading-bar/health.svg)

```
[![Health](https://phpackages.com/badges/stilliard-generic-loading-bar/health.svg)](https://phpackages.com/packages/stilliard-generic-loading-bar)
```

###  Alternatives

[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[bepsvpt/blurhash

A PHP implementation of BlurHash with Laravel integration.

130302.5k7](/packages/bepsvpt-blurhash)[qinchen/web-utils

A web application common utils

111.5k](/packages/qinchen-web-utils)

PHPackages © 2026

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