https://github.com/icanhazstring/symfony-console-spinner
Custom symfony progressbar displaying a spinner
https://github.com/icanhazstring/symfony-console-spinner
Last synced: about 1 year ago
JSON representation
Custom symfony progressbar displaying a spinner
- Host: GitHub
- URL: https://github.com/icanhazstring/symfony-console-spinner
- Owner: icanhazstring
- License: mit
- Created: 2020-02-14T16:25:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-27T13:05:12.000Z (over 2 years ago)
- Last Synced: 2025-03-28T05:01:39.460Z (over 1 year ago)
- Language: PHP
- Size: 104 KB
- Stars: 30
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# symfony-console-spinner
Custom symfony progressbar with a spinner.
I wanted a progressbar displaying a long running task like
waiting for an external resource to be available. This is where I
stumbled upon [alecrabbit/php-cli-snake](https://github.com/alecrabbit/php-cli-snake).
I tried to mimic the the animation using symfony/console and this
is the result:

## Installation
Use composer to require the small package
```bash
composer require icanhazstring/symfony-console-spinner
```
## Usage
To use the spinner, just instantiate the `SpinnerProgress` like the
default `ProgressBar` from symfony giving it the `OutputInterface` and
the maximum count of items to process:
```php
public function execute(OutputInterface $output, InputInterface $input)
{
$spinner = new SpinnerProgress($output, 100);
for($i = 0; $i < 100; $i++) {
usleep(1000);
$spinner->advance();
}
$spinner->finish();
}
```
You can also get the underlying `ProgressBar` instance if you want to change anything, for example adding the elapsed time to the output format:
```php
$spinner = new SpinnerProgress($output, 100);
$spinner->getProgressBar()->setFormat('%bar% (%elapsed:6s%) %message%');
```
## License
This package is released under the [MIT license](LICENSE).