Fancy activity indicators for the terminal
Go to file
2024-03-07 01:06:40 +01:00
examples Added wide braille spinner style 2022-10-05 20:59:13 +02:00
src Added width to StyleInterface 2024-03-07 01:06:40 +01:00
.gitignore Initial commit 2022-09-22 01:49:58 +02:00
composer.json Initial commit 2022-09-22 01:49:58 +02:00
LICENSE Initial commit 2022-09-22 01:49:58 +02:00
README.md Updated readme 2022-09-22 02:27:14 +02:00

Console Spinners

Spinners for the console.

Install

Recommended is to install using composer. Add the repository to your global ~/.config/composer/config.json file:

{
  "repositories": [
    {
      "type": "composer",
      "url": "https://dev.noccylabs.info/api/packages/noccy/composer"
    }
  ]
}

Then add the package as a dependency:

$ composer require noccylabs/spinner

Usage

use NoccyLabs\Spinner\Spinner;
use NoccyLabs\Spinner\Style;

// Create a spinner with default options
$spinner = new Spinner();

// Set the default options, will apply to everything created after
Spinner::setDefaultStyle(Style\BrailleDotStyle::class);
Spinner::setDefaultFps(10);
$spinner = new Spinner();

// Or create a custom spinner
$spinner = new Spinner(MyCustomSpinnerStyle::class);
$spinner = new Spinner(FancyStyle::class, fps:20);

// String casting hides all the magic! Just cast the spiner to a string,
// and the frames will advance to match the framerate as long as it is
// rendered at least as often as its set framerate
while(true) {
    echo "\r $spinner ";
    usleep(10000);
}

Included styles

Style Width Notes
BrailleDotStyle 1 A snake chasing its tail, new "docker compose" style
RollingBallStyle 1 A rolling ball, "symfony new" style
SpinnerStyle 2 four-part spinner, 2 characters wide