Monday, May 22, 2017

$this->table() Throws [InvalidArgumentException] A row must be an array or a TableSeparator instance

I've written a L4 Command class but the table output is throwing an exception.

<?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.

    }
}

Any ideas?



via Luke

Advertisement