承接 sevenecks/tableify 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sevenecks/tableify

最新稳定版本:0.0.5

Composer 安装命令:

composer require sevenecks/tableify

包简介

Transform a multidimensional array into a pretty table that can be echoed to the screen or logged to a file.

README 文档

README

Convert multi-dimensional PHP arrays into printable / loggable tables, with headers and everything!.

Installation

Via Composer

composer require sevenecks/tableify

Overview

Using method chaining is the best way to use this package. It makes for a simple, readable syntax. All the public methods aside from toArray() are chainable, in that they modify the instance of the Tableify object and return the object itself.

Example Usage

<?php
require_once __DIR__ . '/../vendor/autoload.php';
use SevenEcks\Tableify\Tableify;

$data = [
    ['Name', 'Date', 'Phone', 'Age'],
    ['Altec Lansing', '03/22/18', '617-555-0584', '30'],
    ['Fack', '03/22/18', '508-555-0584', '24'],
    ['Seven Ecks', '03/22/18', '+1-888-555-0584', '100'],
    ['CK', '03/22/18', 'N/A', '33'],
    ['Jason Jasonson', '03/22/18', '978-555-0584', '34'],
    ['Waxillium Wick', '03/22/18', '978-555-0584', '34'],
    ['Ruby Reide', '03/22/18', '978-555-0584', '34'],
    ['Rex Gold', '03/22/18', '978-555-0584', '34'],
    ['Juicy Vee', '03/22/18', '978-555-0584', '34'],
];

echo "Table Construction using default values on class and no method chaining:\n";
$table = Tableify::new($data);
$table = $table->make();
$table_data = $table->toArray();
foreach ($table_data as $row) {
    echo $row . "\n";
}

echo "Table Construction using method chaining:\n";
$table_rows = Tableify::new($data)->center()->seperatorPadding(2)->seperator('*')->headerCharacter('@')->make()->toArray();
foreach ($table_rows as $row) {
    echo $row . "\n";
}
// display the help list
foreach (Tableify::help() as $row) {
    echo $row . "\n";
}

This code will result in the following tables being generated:

Table Construction using default values on class and no method chaining:
-----------------------------------------------------
| Name           | Date     | Phone           | Age |
-----------------------------------------------------
| Altec Lansing  | 03/22/18 | 617-555-0584    | 30  |
| Fack           | 03/22/18 | 508-555-0584    | 24  |
| Seven Ecks     | 03/22/18 | +1-888-555-0584 | 100 |
| CK             | 03/22/18 | N/A             | 33  |
| Jason Jasonson | 03/22/18 | 978-555-0584    | 34  |
| Waxillium Wick | 03/22/18 | 978-555-0584    | 34  |
| Ruby Reide     | 03/22/18 | 978-555-0584    | 34  |
| Rex Gold       | 03/22/18 | 978-555-0584    | 34  |
| Juicy Vee      | 03/22/18 | 978-555-0584    | 34  |
-----------------------------------------------------
Table Construction using method chaining:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*       Name       *    Date    *       Phone       *  Age  *
-------------------------------------------------------------
*  Altec Lansing   *  03/22/18  *   617-555-0584    *  30   *
*       Fack       *  03/22/18  *   508-555-0584    *  24   *
*    Seven Ecks    *  03/22/18  *  +1-888-555-0584  *  100  *
*        CK        *  03/22/18  *        N/A        *  33   *
*  Jason Jasonson  *  03/22/18  *   978-555-0584    *  34   *
*  Waxillium Wick  *  03/22/18  *   978-555-0584    *  34   *
*    Ruby Reide    *  03/22/18  *   978-555-0584    *  34   *
*     Rex Gold     *  03/22/18  *   978-555-0584    *  34   *
*    Juicy Vee     *  03/22/18  *   978-555-0584    *  34   *
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-------------------------------------------------------------------------------------
| Method                       | Description of Method                              |
-------------------------------------------------------------------------------------
| Tableify::new(array)         | Static method to create a new instance             |
| center()                     | Set the formatter to use the center method         |
| left()                       | Set the formatter to use the left method           |
| right()                      | set the formatter to use the right method          |
| setData(array)               | Set the data array on the object                   |
| seperatorPadding(string)     | Set the # of blank characters around the seperator |
| seperator(string)            | Set the seperator string                           |
| headerCharacter(string)      | Set the header character                           |
| belowHeaderCharacter(string) | Set the below header character string              |
| make()                       | Make the data into an array of table rows          |
| toArray()                    | Return the array of table rows                     |
| Tableify::help()             | Display this help!                                 |
-------------------------------------------------------------------------------------

TableifyInterface

The TableifyInterface allows you to implement your own Tableify in whatever means you want while maintaining the same public facing interface. You can use dependency injection to insert your own if you have a dependency injection container.

Change Log

Please see Change Log for more information.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固