定制 lupecode/console 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

lupecode/console

Composer 安装命令:

composer require lupecode/console

包简介

A library for printing to the console.

README 文档

README

What is it?

This library is a console helper for ANSI colors, progress bars, and tables.

If you have a console that is not Windows command prompt, and you can have color in your console, this library will help you jazz up your PHP console applications.

Requirements

This library requires PHP >= 7.0.

Readline

If you wish to use Console::readline, Console::promptReadline, or Console::optionsReadline you will need to have the readline module loaded in PHP. On Windows, this requires PHP >= 7.1.0

Installation

The best way to install this console helper is to use Composer.

composer require lupecode/console

How To

tl;dr

See the tests folder.

Basic Print

Console::print('Hello World'); // Will not print a new line at the end
Console::printLine('Hello World'); // Will print a new line at the end

Built-in Styles

Console has a few built-in styles.

Console::printHeader('Header Message'); // Prints the text in a yellow box
Console::printDebug('Debug Message'); // Prints the text in a gray color
Console::printError('Error Message'); // Prints the text in a red color
Console::printStatus('Status Message'); // Prints the text in a blue color
Console::printSuccess('Success Message'); // Prints the text in a green color

16 Color Palette

Console has support for 16 color palette.

$color = new Color16();
$color
    ->setBackgroundColor(Color::YELLOW)
    ->setForegroundColor(Color::BLACK)
    ->setFlag(Color::BOLD)
;
Console::printLine('Print Line In Color', $color);

256 Color Palette

Console has support for 256 color palette. These colors range with RGB from 0 to 5 for 216 colors. There are 24 levels of grayscale.

$color = new Color256();
$color
    ->setBackgroundColor(5,5,0)
    ->setForegroundColorGrayscale(0)
    ->setFlag(Color::BOLD)
;
Console::printLine('Print Line In Color', $color);

Progress Bars

Console has support for progress bars.

$pBar = Console::progressBar();
$pBar->setBarSize(30)->setTotal(100)->startTimer();
for ($i = 0; $i < 100; $i++) {
    $pBar->increment();
}
$pBar->finish();

Tables

Console has support for tables.

Console::table()
   ->addColumn('ID')
   ->addColumn('Title')
   ->addColumn('ISBN')
   ->addRow([1, 'Lorem Ipsum and the Valley of Goblins', '987-12345678-1'])
   ->addRow([2, 'Lorem Ipsum and the Chair of Sadness', '987-12345678-2'])
   ->addRow([3, 'Lorem Ipsum and the Sands of Itchiness', '987-12345678-3'])
   ->addRow([4, 'Lorem Ipsum and the Lingua Franca', '987-12345678-4'])
   ->printTable()
;

lupecode/console 适用场景与选型建议

lupecode/console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 lupecode/console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lupecode/console 我们能提供哪些服务?
定制开发 / 二次开发

基于 lupecode/console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2019-05-17