我刚刚在Laravel 控制台命令中发现了表格渲染功能。
我的项目是基于 Laravel 5.8 构建的,但即使有更高级版本的答案,也很高兴知道。
我正在寻找一个具有确定(甚至更好 - 有限)列宽的表格。就像是:
$data = [
['John', 'The Curious Incident of the Dog in the Night-Time'],
['Rachel', 'The Catcher in the Rye']
];
// Code for columns width is missing
$this->table(['Name', 'Favorite book'], $data);
所以输出将是:
+--------+-------------------------+
| Name | Favorite book |
+--------+-------------------------+
| John | The Curious Incident... |
| Rachel | The Catcher in the Rye |
+--------+-------------------------+
我看到Symfony 表(laravel 表所基于)有一个setColumnWidths()
功能,但我无法从控制台命令中找到任何使用它的方法。
有人知道这是否可能吗?