php-console icon indicating copy to clipboard operation
php-console copied to clipboard

Use console.table() in Chrome extension

Open Chi-teck opened this issue 10 years ago • 7 comments

I think it would be handy especially for tabular data.

Chi-teck avatar Nov 22 '13 07:11 Chi-teck

Give me please some example :)

barbushin avatar Nov 22 '13 08:11 barbushin

$dispatcher =  $connector->getDebugDispatcher();
$dispatcher->setFormatter('table');
$data = $db->query('SELECT * FROM table')->fetchAll();

// Take column headers from object/array properties.
$dispatcher->dispatchDebug($data, 'Big table with all available columns');

// Specifiy column headers directly. 
$dispatcher->setTableHeaders(['Header 1', 'Header 2', 'Header 3']);
$dispatcher->dispatchDebug($data, 'Simple three-column table');

// Add row numbers.
$dispatcher->setTableRowNumbers(TRUE);
$dispatcher->dispatchDebug($data, 'The same table with row numbers column');

Chi-teck avatar Nov 22 '13 10:11 Chi-teck

Oh noo, it's too complicated to get used :) I think I will just add some options on client like:

Table-tags. [x] sql [x] db [ ] some [ ] other

So when there will be sql & db tags in message, it will be grouped to a table with field sql, db.

barbushin avatar Nov 22 '13 11:11 barbushin

I think, some facade shortcut like PC::table(array | Traversable $data, [array $headers]) will be very handy.

velosipedist avatar Jan 22 '14 14:01 velosipedist

@velosipedist Good idea, thank you! I think I'll implement it soon.

barbushin avatar Jan 24 '14 08:01 barbushin

Perhaps we could use signature of native chrome console.table function as ChromePHP extension does.

query-log

Chi-teck avatar Oct 26 '14 04:10 Chi-teck

@barbushin Hi. Any progress on this? It would be very handy. I am using console.table() a lot to output Objects/Json when debugging JS. Having option to output PHP arrays (and possibly JSON) as table would be very handy.

LorincJuraj avatar Jan 08 '19 21:01 LorincJuraj