【发布时间】:2020-03-29 10:39:49
【问题描述】:
本文展示了 laravel 的 artisan 命令支持 $this->table($headers, $data),它在后台使用“Symfony Table Helper”来显示来自标量数组的 cli 表。
http://symfony.com/doc/current/components/console/helpers/tablehelper.html
我想在 phpunit 中使用这个功能进行调试。
$ 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].'
>>>
现在我不知道如何实例化辅助对象。我想做一个dump_table 函数,可以在tinker 和phpunit 中使用,类似于现有的dump 助手。
【问题讨论】:
标签: php laravel symfony laravel-5 phpunit