Skip to content

Use Vardumper with console helper table for dumping tabular data as a table? #34793

Closed
@carcinocron

Description

@carcinocron

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:
artisan-table.

I'd like to use this hypothetical "table_dump" feature in the php artisan tinker and phpunit contexts.

$ php artisan tinker
Psy Shell v0.9.9 (PHP 7.2.24-0ubuntu0.18.04.1 — cli) by Justin Hileman
>>> new Symfony\Component\Console\Helper\Table()
TypeError: Too few arguments to function Symfony/Component/Console/Helper/Table::__construct(), 0 passed in Psy Shell code on line 1 and exactly 1 expected
>>> app(\Symfony\Component\Console\Output\OutputInterface::class)
Illuminate/Contracts/Container/BindingResolutionException with message 'Target [Symfony/Component/Console/Output/OutputInterface] is not instantiable.'
>>> app()->make(\Symfony\Component\Console\Output\OutputInterface::class)
Illuminate/Contracts/Container/BindingResolutionException with message 'Target [Symfony/Component/Console/Output/OutputInterface] is not instantiable.'
>>> app()->make(\Symfony\Component\Console\Helper\Table::class)
Illuminate/Contracts/Container/BindingResolutionException with message 'Target [Symfony/Component/Console/Output/OutputInterface] is not instantiable while building [Symfony/Component/Console/Helper/Table].'
>>>

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions