psdi/motif 问题修复 & 功能扩展

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

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

psdi/motif

Composer 安装命令:

composer require psdi/motif

包简介

PHP CLI output formatter

README 文档

README

A simple PHP tool for formatting output text on a terminal.

Installation

Install using composer:

composer require psdi/motif [--no-dev]

Include the flag --no-dev if you want to omit installing PHPUnit (which isn't exactly a lightweight framework).

Usage

The Formatter class has three main output functions:

  • format takes a string as well as a style string

The style string has the following syntax: [format,styles]|color:[color]|bg:[background]. The order of the styles doesn't matter; you can even omit them.

  • formatLine expands on format; however, it appends a line break to the text
  • display accepts a text as well as a mode (success, warning, error, info). The function prints the text with the corresponding background color (green, yellow, red, blue).
<?php
// index.php
require 'vendor/autoload.php';
use Motif\Formatter;

// [1] Prints 'Hello, world!' (bold and underlined) in green on console
echo Formatter::formatLine('Hello, world!', 'bold|color:green');

// [2,3] Examples with and without line breaks
echo Formatter::format('Somebody once told me,', 'strike|color:black|bg:blue');
echo Formatter::formatLine(' the world was gonna roll me.', 'underline|color:cyan');

// [4] Prints 'Error downloading files.' in white with a red background
echo Formatter::display('Error downloading files.', 'error');

// [5,6,7] Some more examples
echo Formatter::formatLine('This is a sample text. ', 'bold,italic|color:yellow');
echo Formatter::formatLine(
    'This is also a sample text, but in magenta.',
    'italic|color:magenta'
);
echo Formatter::display('Success! •ᴗ•', 'success');

The above code would bring about:

Contributions

If you spot bugs or have any suggestions, feel free to add them to the issue tracker.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-03-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固