35 lines
802 B
Markdown
35 lines
802 B
Markdown
|
# Console Spinners
|
||
|
|
||
|
Spinners for the console.
|
||
|
|
||
|
## Install
|
||
|
|
||
|
Install using composer.
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
```php
|
||
|
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);
|
||
|
}
|
||
|
```
|