定制 gurubob/ascii-table 二次开发

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

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

gurubob/ascii-table

最新稳定版本:v0.2.2

Composer 安装命令:

composer create-project gurubob/ascii-table

包简介

Simple ASCII output of array data

README 文档

README

Features

  • Create tables suitable for CLI output quickly
  • No external dependencies

View/run example.php for examples. This file is the output of that script:

Create table via constructor:
┌───────────────────┬─────────────┐
│ Name              │ Country     │
├───────────────────┼─────────────┤
│ Bob Brown         │ New Zealand │
│ Wolfgang Puck     │ America     │
│ Winston Churchill │ England     │
└───────────────────┴─────────────┘

Create table via OO interfaces:
┌───────────────────┬───────────────┐
│ Sales Agent       │ Travelling To │
├───────────────────┼───────────────┤
│ Bob Brown         │ New Zealand   │
│ Wolfgang Puck     │ America       │
│ Winston Churchill │ England       │
└───────────────────┴───────────────┘

Output same table with different headers (reusing defined table):
┌───────────────────┬─────────────────────┐
│ Favourite Person  │ County Of Residence │
├───────────────────┼─────────────────────┤
│ Bob Brown         │ New Zealand         │
│ Wolfgang Puck     │ America             │
│ Winston Churchill │ England             │
└───────────────────┴─────────────────────┘

ASCII borders instead of box:
+-------------------+---------------------+
| Favourite Person  | County Of Residence |
+-------------------+---------------------+
| Bob Brown         | New Zealand         |
| Wolfgang Puck     | America             |
| Winston Churchill | England             |
+-------------------+---------------------+
Note: Made a copy() so that the following header would retain box format.

Table with no headers:
┌───────────────────┬─────────────┐
│ Bob Brown         │ New Zealand │
│ Wolfgang Puck     │ America     │
│ Winston Churchill │ England     │
└───────────────────┴─────────────┘

Create by chaining setters and adding individual rows:
╔══════════╦═══════╗
║ Product  ║ Price ║
╠══════════╬═══════╣
║ Apples   ║ $1.29 ║
║ Bananas  ║ $1.69 ║
║ Cherries ║ $2.99 ║
╚══════════╩═══════╝

Create by passing a collection (an array of arrays) as the first parameter:
┌─────────────────┬──────────┬─────────────────────┐
│ name            │ language │ timezone            │
├─────────────────┼──────────┼─────────────────────┤
│ Bob Brown       │ English  │ Pacific/Auckland    │
│ Roberto Collazo │ Spanish  │ America/Mexico_City │
│ Naya Yasotaro   │ Japanese │ Asia/Tokyo          │
└─────────────────┴──────────┴─────────────────────┘

Exclude the name column (via except()):
┌──────────┬─────────────────────┐
│ language │ timezone            │
├──────────┼─────────────────────┤
│ English  │ Pacific/Auckland    │
│ Spanish  │ America/Mexico_City │
│ Spanish  │ America/Mexico_City │
└──────────┴─────────────────────┘

Only show the name and timezone column (via only()):
┌─────────────────┬─────────────────────┐
│ name            │ timezone            │
├─────────────────┼─────────────────────┤
│ Bob Brown       │ Pacific/Auckland    │
│ Roberto Collazo │ America/Mexico_City │
│ Roberto Collazo │ America/Mexico_City │
└─────────────────┴─────────────────────┘

Note: Use of only() and except() are mutually exclusive - setting one will unset the other

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: WTFPL
  • 更新时间: 2018-11-13