barbushin / php-console

Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome
https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
MIT License
1.34k stars 283 forks source link

Use console.table() in Chrome extension #23

Open Chi-teck opened 10 years ago

Chi-teck commented 10 years ago

I think it would be handy especially for tabular data.

barbushin commented 10 years ago

Give me please some example :)

Chi-teck commented 10 years ago
$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');
barbushin commented 10 years ago

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.

velosipedist commented 10 years ago

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

barbushin commented 10 years ago

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

Chi-teck commented 9 years ago

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

query-log

LorincJuraj commented 5 years ago

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