-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Use Vardumper with console helper table for dumping tabular data as a table? #34793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
can you describe the hypothetical "table_dump" feature 😕 or what "existing functionality" do you mean? In general if you want to use VarDumper + Console table; see #28898, that should help using dumps in table cells. |
I don't need the dumps inside the table cells, I need to dump the array of data itself as a table like in the picture. Basically I want to be able to run this code from here public function handle()
{
$headers = ['Name', 'Awesomeness Level'];
$data = [
[
'name' => 'Jim',
'awesomeness_level' => 'Meh',
],
[
'name' => 'Conchita',
'awesomeness_level' => 'Fabulous',
],
];
/* Note: the following would work as well:
$data = [
['Jim', 'Meh'],
['Conchita', 'Fabulous']
];
*/
$this->table($headers, $data); // <---- specifically this line, but perhaps renamed as dump_table($headers, $data)
} but I need it to work in the phpunit and tinker context, like how I'm pretty sure the code already exists in https://github.com/symfony/console/blob/master/Helper/Table.php but I can't figure out how to instantiate that class. |
oh got ya.. basically a horizontal display when doing Im not sure this is a common enough feature for debugging :/ IMHO |
|
yes, but the problem may shift to horiztonal scrolling instead. Gave it some thought, and i tend to be 👎 for array structures to be interpreted as tabular data (and rendered as such). That's outside the VarDumper scope IMHO, which should just dump the array conform its structure. |
I just want to know how to use the code that already exists. |
you can render a table, as per https://symfony.com/doc/current/components/console/helpers/table.html for
|
thanks, this worked:
|
I'd like to use https://github.com/symfony/console/blob/master/Helper/Table.php in a similar manor to
.
dump()
. I know that the console command has a nice table helper as shown in here like this:I'd like to use this hypothetical "table_dump" feature in the
php artisan tinker
andphpunit
contexts.How would you do this? I tried reading laravel's code but it's just infinite layers of automagic.
It would be cool if this existing functionality was exposed as
dump_table($data)
The text was updated successfully, but these errors were encountered: