wilensky/cli-colorizer 问题修复 & 功能扩展

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

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

wilensky/cli-colorizer

Composer 安装命令:

composer require wilensky/cli-colorizer

包简介

A lightweight tool for easy PHP7 CLI output coloring.

README 文档

README

Lightweight PHP7 CLI output colorizer

  • Available via composer require wilensky/cli-colorizer
  • PHP7 compliant
  • PSR2 compliant
  • Lightweight
  • Documented
  • Compatible with native linux tail and cat commands

Usage

For ease of use CliColorizer can/should be aliased with help of use statement.

<?php

use Wilensky/CliColorizer as WCC;

Changing text color

Regular method

echo WCC::fgYellow('YoHoHo').PHP_EOL; // YoHoHo will be yellowed on default background

All available foregroung color @methods are listed under the class docblock with fg* prefix.

Advanced method

$answer = true;
$isOk = $answer === true;

echo WCC::fg(
	$isOk ? 'Yes' : 'No',
	$isOk ? 'green' : 'red'
).PHP_EOL;

Changing background color

Regular method

echo WCC::bgCyan('YoHoHo').PHP_EOL; // YoHoHo will be displayed on cyan background with default foreground color

All availabe backgorund color @methods are listed under the class docblock with bg* prefix.

Advanced method

$error = true;
$hasError = $error === true;

echo WCC::bg(
	$hasError ? 'Failed' : 'Ready',
	$hasError ? 'red' : 'black'
).PHP_EOL;

Mixing fore and background colors

echo WCC::bgGreen(WCC::fgYellow('YoHoHo')).PHP_EOL; // YoHoHo will be displayed as yellow text on green background
echo WCC::fgYellow(WCC::bgGreen('YoHoHo')).PHP_EOL; // Produces same output as invocation priority doesn't matter for display

Making text bold

echo WCC::bold('YoHoHo').PHP_EOL; // YoHoHo will be displayed bold with default fore/background colors

Making bold colors

echo WCC::bold(WCC::fgYellow('YoHoHo')).PHP_EOL; // YoHoHo will be bold yellow
echo WCC::fgYellow(WCC::bold('YoHoHo')).PHP_EOL; // Produces same output
echo WCC::bold(WCC::bgCyan('YoHoHo')).PHP_EOL; // YoHoHo will be bold with default color on cyan background
echo WCC::bold(WCC::fgYellow(WCC::bgCyan('YoHoHo'))).PHP_EOL; // YoHoHo will be bold yellow on cyan background

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固