php-console
php-console copied to clipboard
Use console.table() in Chrome extension
I think it would be handy especially for tabular data.
Give me please some example :)
$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');
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.
I think, some facade shortcut like PC::table(array | Traversable $data, [array $headers])
will be very handy.
@velosipedist Good idea, thank you! I think I'll implement it soon.
Perhaps we could use signature of native chrome console.table function as ChromePHP extension does.
@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.