This article shows that laravel' artisan commands support $this->table($headers, $data)
which uses "Symfony Table Helper" under the hood to display a cli table from arrays of scalars.
http://symfony.com/doc/current/components/console/helpers/tablehelper.html
I would like to use this functionality inside phpunit for debugging.
$ 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].'
>>>
Right now I can't figure out how to instantiate the helper object. I would like to make a dump_table
function that can be used in tinker and phpunit similar to the existing dump
helper.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire