rodrigopedra/table-stream
最新稳定版本:v1.2.0
Composer 安装命令:
composer require rodrigopedra/table-stream
包简介
Writes continous tabular data to CLI
README 文档
README
Writes continous tabular data to CLI.
Requirements
- PHP 7.4+
mbstringextension
Installation
composer require rodrigopedra/table-stream
Usage
<?php require './vendor/autoload.php'; use Rodrigopedra\TableStream\Column; use Rodrigopedra\TableStream\Table; $table = new Table([ // first parameter is the column's header // second is your estimated cell width // third is the cell alignment new Column('#', 8, Column::ALIGN_CENTER), // Column::ALIGN_LEFT is the default alignment new Column('Date', 19), // Fluent "wither" method are also avaialable Column::make('Value')->width(13)->alignRight(), ]); // re-writes header overy 5 rows $table->offset(5); foreach (\range(1, 10) as $index) { $table->appendRow([ \number_format($index), \date('Y-m-d H:i:s'), \uniqid(), ]); \sleep(1); } $table->close();
- By the default it uses
echoto output data - You can provide a custom
OutputInterfaceimplementation instead - See
./src/SymfonyOutputfor an example usingSymfony\Component\Console\Output\OutputInterfacefromsymfony/console
Sample Output
Click to expand
+----------+---------------------+---------------+
| # | Date | Value |
+----------+---------------------+---------------+
| 1 | 2023-08-14 21:48:06 | 64daa11634d36 |
| 2 | 2023-08-14 21:48:07 | 64daa11734dbb |
| 3 | 2023-08-14 21:48:08 | 64daa11834e23 |
| 4 | 2023-08-14 21:48:09 | 64daa11934e76 |
| 5 | 2023-08-14 21:48:10 | 64daa11a34ec7 |
+----------+---------------------+---------------+
| # | Date | Value |
+----------+---------------------+---------------+
| 6 | 2023-08-14 21:48:11 | 64daa11b34f17 |
| 7 | 2023-08-14 21:48:12 | 64daa11c34f93 |
| 8 | 2023-08-14 21:48:13 | 64daa11d34fe7 |
| 9 | 2023-08-14 21:48:14 | 64daa11e35041 |
| 10 | 2023-08-14 21:48:15 | 64daa11f35093 |
+----------+---------------------+---------------+
License
This package is open-sourced software licensed under the MIT license
统计信息
- 总下载量: 49
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-14