isaeken/spinner
Composer 安装命令:
composer require isaeken/spinner
包简介
Elegant spinner for interactive CLI apps.
README 文档
README
Elegant spinner for interactive CLI apps.
PHP alternative for https://github.com/sindresorhus/elegant-spinner
use IsaEken\Spinner\Spinner;$result = Spinner::run(function () { Spinner::setTitle('Calculating...'); $a = 1; $b = 2; $c = $a + $b; Spinner::setTitle('Waiting...'); sleep($c); return $c; }); echo "The result is: $result!";
Requirements
- PHP ^8.0
- Windows or Unix (Tested on Windows 10)
- PCNTL extension suggested on unix systems.
Icons work properly in Windows Terminal application. You can create theme to remove or change icons.
Installation
You can install using composer.
composer require isaeken/spinner
Examples
use IsaEken\Spinner\Enums\Status; use IsaEken\Spinner\Spinner; use IsaEken\Spinner\Themes\ClassicTheme; // create spinner (you do not needed this because the 'run' command are automatically creates an instance.) $spinner = new Spinner(); // or $spinner = Spinner::getInstance(); // create a spinner process // with theme $execution_result = Spinner::run(fn () => 'Hello World!', ClassicTheme::class); // without theme $execution_result = Spinner::run(function () { // get the spinner instance. $spinner = Spinner::getInstance(); // set the process title. Spinner::setTitle('Hello World!'); // alternative $spinner->setTitle('Hello World!'); // set the process status. Spinner::setStatus(Status::Success); Spinner::setStatus(Status::Warning); Spinner::setStatus(Status::Failed); // the end of process return 'Hello World!'; }); echo $execution_result; // Hello World!
Example Theme
use Illuminate\Support\Collection; use IsaEken\Spinner\Enums\Status; use IsaEken\Spinner\Interfaces\ThemeInterface; use IsaEken\Spinner\Themes\DefaultTheme; class ExampleTheme extends DefaultTheme implements ThemeInterface { /** * @inheritDoc */ public static function frames(): Collection { return collect([ '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏', ]); } /** * @inheritDoc */ public static function icons(): Collection { return collect([ Status::Success => '✔️', Status::Warning => '⚠️', Status::Failed => '❌', ]); } /** * @inheritDoc */ public static function messages(): Collection { return collect([ Status::Success => 'Process successfully completed.', Status::Warning => 'Process completed but the warnings alerted.', Status::Failed => 'Process cannot be completed successfully.', ]); } /** * @inheritDoc */ public static function colors(): Collection { return collect([ Status::Success => "\e[32m", Status::Warning => "\e[33m", Status::Failed => "\e[31m", ]); } }
License
The MIT License (MIT). Please see License File for more information.
isaeken/spinner 适用场景与选型建议
isaeken/spinner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 8, 最近一次更新时间为 2021 年 06 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 isaeken/spinner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 isaeken/spinner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-20
