I have just discovered the table rendering function in Laravel console command.
My project is built on Laravel 5.8, but even if there is an answer for more advanced versions it will be great to know.
I am looking for rendering a table with determined (or even better - limitted) column width. Something like:
$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);
So the output will be:
+--------+-------------------------+
| Name | Favorite book |
+--------+-------------------------+
| John | The Curious Incident... |
| Rachel | The Catcher in the Rye |
+--------+-------------------------+
I saw that Symfony table (which laravel table is based on) has a setColumnWidths()
function, but I cannot find any way to use it from the console command.
Does somebody know if it is possible?