Luk*_*uke 6 command-line symfony laravel laravel-4
我写了一个L4 Command类,但table输出抛出异常.
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class Table extends Command {
protected $name = 'table';
public function fire()
{
//output table;
$header = ['Name', 'Email', 'Age'];
$row = ['Luke', 'me@email.uk', '99'];
$this->info(sprintf("is array ? %s", is_array($row) ? 'true' : 'false'));
//outputs is array ? true
$this->table($header, $row);
//throws exception
// [InvalidArgumentException]
// A row must be an array or a TableSeparator instance.
}
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
您必须传入一组行.根据table定义:
void table(array $headers, array $rows, string $style = 'default')
Run Code Online (Sandbox Code Playgroud)
所以你要么做
$row = [['Luke', 'me@email.uk', '99']]; // An array of arrays, containing one row
Run Code Online (Sandbox Code Playgroud)
要么
$this->table($header, [$row]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1271 次 |
| 最近记录: |