Giter Club home page Giter Club logo

cli-message's Introduction

Cli Message

Let your php output in command line colorful.

效果预览

样例 支持的颜色

要求

  • PHP >= 5.4

使用方法

安装

composer require "chency147/cli-message"

使用示例

$style = new Style();
$style->setForegroundColor(Style::COLOR_GREEN) // 定义颜色为绿色
      ->setBold() // 设置加粗
      ->setUnderLine(); // 设置显示下划线
$message = new Message();
$message->setStyle($style); // 给消息设定样式
$message->setContent('哈哈哈!'); // 设置消息内容
echo $message, PHP_EOL; // 重写了__toString方法,消息对象可直接作为字符串使用

// 也可以用getContentWithStyle方法来获取处理后的字符串进行输出
echo $message->getContentWithStyle(), PHP_EOL;

$anotherStyle = new Style();
$anotherStyle->setForegroundColor(Style::COLOR_RED);
echo $message->getContentWithStyle($anotherStyle, PHP_EOL);

颜色说明

  • 颜色由0到255的整数来控制,可参照效果预览中的颜色表来选择自己所需的颜色;

协议

本项目使用MIT协议。

cli-message's People

Contributors

chency147 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.