Spinner - your task is running
🏵️ PHP Console Spinner
⚠️ Compatibility issues
Update 2019-Nov-01: As of version
0.53compatibility issues should be resolved, but it needs to be tested.
This project is still in its active development phase. It turned out that some of its indirect dependencies are causing compatibility issues. New release is expected to be ready in mid-november 2019. For now, as a solution, you can use lightweight spinner alecrabbit/php-cli-snake.
Feature comparision
| Feature | php-console-spinner | php-cli-snake |
|---|---|---|
| Lightweight | ||
| Has zero dependencies | ||
| Highly configurable | ||
| Contains various spinner classes | ||
| Progress indicator | ||
| Messages indicator | ||
| Color settings for spinner | ||
| Color settings for messages | ||
| Color settings for progress indicator | ||
Has disable() method |
||
Has enable() method |
||
| Can show final message | ||
| Cursor hide can be disabled | ||
| Can use optional custom output | ||
Has erase() method |
||
Hides cursor with $spinner->begin() |
||
Shows cursor with $spinner->end() |
||
| Supports piping | ||
| Supports redirect | ||
Supports no color mode |
||
Supports 16 color mode |
||
Supports 256 color mode |
Features
- progress indication during spin
$spinner->progress(0.5)➙50% - messages during spin
$spinner->message('message') - separated color settings for spinner, messages and progress indicator
- has
disable()andenable()methods - hides cursor on
$spinner->begin(), shows on$spinner->end() - cursor hide can be disabled
$settings->setHideCursor(false) - has
erase()method - final message
$spinner->end('final message') - supports unix pipe
|and redirect>output - supplied with
SymfonyOutputAdapter::class
Quickstart
Simple
See simple.php
require_once __DIR__ . '/vendor/autoload.php';
use AlecRabbit\Spinner\SnakeSpinner;
const ITERATIONS = 50;
$spinner = new SnakeSpinner();
$spinner->begin();
for ($i = 0; $i <= ITERATIONS; $i++) {
usleep(80000); // Simulating work
$spinner->spin();
}
$spinner->end();Advanced (ReactPHP)
require_once __DIR__ . '/../vendor/autoload.php';
use AlecRabbit\Spinner\BlockSpinner;
use React\EventLoop\Factory;
$s = new BlockSpinner();
$loop = Factory::create();
$loop->addPeriodicTimer($s->interval(), static function () use ($s) {
$s->spin();
});
$s->begin();
$loop->run();Installation
composer require alecrabbit/php-console-spinnerUsage
- Unix pipe and redirect
- See examples
- Examples output casts
Spinners
Here you can find a list of all spinners with demos
Operating Systems
-
Developed and tested on Ubuntu 18.04 (xterm terminal)
-
On Windows it should work in any VT100 terminal, e.g. minTTY.
Links
- Inspired by sindresorhus/cli-spinners

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.



