ckoumpis/php-prompt 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ckoumpis/php-prompt

最新稳定版本:v2.0.0

Composer 安装命令:

composer require ckoumpis/php-prompt

包简介

A PHP console utility package providing spinners, progress bars, and error handling for better command-line user experience.

README 文档

README

A PHP console utility package that provides spinners, progress bars, and color-coded console messages for better command-line user experience.

Installation

To install the PhpPrompt, you need to have Composer installed.

composer require ckoumpis/php-prompt

Usage

Console

The Console class provides several methods to output colored messages.

List of available colors

  • White: For simple logs (white)
  • Success: For success messages (green)
  • Error: For error messages (red)
  • Warning: For warning messages (yellow)
  • Blue: For information messages (blue)
  • Magenta: For important messages (magenta)
  • Cyan: For notifications (cyan)
  • Debug: For debugging (grey)
  • Notice: For notifications (cyan)
Console::log("Hello from ckoumpis/php-prompt!");
Console::success("Operation successful!");
Console::error("An error occurred!");
Console::warning("Warning");
Console::blue("This is a blue message");
Console::magenta("This is a magenta message");
Console::cyan("Cyan message for notification");
Console::debug("Debug testing");
Console::notice("Notice testing");

Progress Bar

The ProgressBar class allows you to visually display the progress of a task. You can use it with 2 ways.

  1. Basic way.
for($i =1; $i <=$total; $i++) {
    ProgressBar::display($i, $total);
    usleep(10000);
}
  1. Using withSteps method
ProgressBar::withSteps(1, 10,1);

Spinner

The Spinner class provides a simple loading animation for console, useful for indicating that an operation is in progress.You can use Spinner bar with 2 ways.

  1. Basic way
for($i = 0; $i < 10; $i++) {
    Spinner::spin();
    sleep(1);
}
  1. Using withSteps method. Or withSteps method
Spinner::withSteps(0, 10, 1);

MemoryUsage

The MemoryUsage class tracks Memory consumption for executed functions.

Usage:

    $start = \Ckoumpis\PhpPrompt\MemoryUsage::getMemoryUsage();
    $arr = array_fill(0, 100000, 'test');
    $end = \Ckoumpis\PhpPrompt\MemoryUsage::getMemoryUsage();
    $memoryUsage = \Ckoumpis\PhpPrompt\MemoryUsage::showMemory($end - $start);

Contributing

We welcome contributions! If you find a bug or have a feature request, please open an issue or submit a pull request on Github.

统计信息

  • 总下载量: 127
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-07