mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-06-09 07:35:04 +02:00
428 lines
12 KiB
HTML
428 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
|
<title>PHP Debug Bar</title>
|
|
<link rel="canonical" href="https://php-debugbar.com/collectors/base/" />
|
|
|
|
<link type="text/css" rel="stylesheet" href="/docs/assets/css/reset.css">
|
|
<link type="text/css" rel="stylesheet" href="http://yandex.st/highlightjs/6.1/styles/sunburst.min.css">
|
|
<link type="text/css" rel="stylesheet" href="/docs/assets/css/docs.css">
|
|
<link type="text/css" rel="stylesheet" href="/docs/assets/css/print.css" media="print">
|
|
<link type="text/css" rel="stylesheet" href="style.css">
|
|
|
|
<script type="text/javascript" src="/docs/assets/js/jquery-1.10.1.min.js"></script>
|
|
<script type="text/javascript" src="http://yandex.st/highlightjs/6.1/highlight.min.js"></script>
|
|
<script type="text/javascript" src="/docs/assets/js/lunr.min.js"></script>
|
|
|
|
|
|
|
|
<script type="text/javascript">var BASE_URL = "/docs/";</script>
|
|
<script type="text/javascript" src="/docs/assets/js/viewer.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<div id="page">
|
|
<a name="top" />
|
|
<header id="header">
|
|
<h1><a href="/docs/">PHP Debug Bar</a></h1>
|
|
</header>
|
|
|
|
|
|
<div id="sidebar">
|
|
<form action="/docs/search.html"><input id="search" type="text" placeholder="Search" name="q" /></form>
|
|
<nav id="toc">
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/readme.html#php-debug-bar">PHP Debug Bar</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/readme.html#installation">Installation</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/readme.html#quick-start">Quick start</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/data-collectors.html#collecting-data">Collecting Data</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/data-collectors.html#using-collectors">Using collectors</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/data-collectors.html#creating-collectors">Creating collectors</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/rendering.html#rendering">Rendering</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/rendering.html#assets">Assets</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/rendering.html#managing-jquery-conflicts">Managing jQuery conflicts</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/rendering.html#the-javascript-object">The javascript object</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/ajax-and-stack.html#ajax-and-stacked-data">AJAX and Stacked data</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/ajax-and-stack.html#ajax">AJAX</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/ajax-and-stack.html#stacked-data">Stacked data</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#base-collectors">Base collectors</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#messages">Messages</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#timedata">TimeData</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#exceptions">Exceptions</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#pdo">PDO</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#requestdata">RequestData</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#config">Config</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#aggregatedcollector">AggregatedCollector</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/base-collectors.html#others">Others</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#bridge-collectors">Bridge collectors</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#cachecache">CacheCache</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#doctrine">Doctrine</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#monolog">Monolog</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#propel">Propel</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#slim">Slim</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#swift-mailer">Swift Mailer</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/bridge-collectors.html#twig">Twig</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/data-formatter.html#data-formatter">Data Formatter</a>
|
|
|
|
|
|
<ol>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/storage.html#storage">Storage</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/storage.html#available-storage">Available storage</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/storage.html#creating-your-own-storage">Creating your own storage</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/storage.html#request-id-generator">Request ID generator</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/openhandler.html#open-handler">Open handler</a>
|
|
|
|
|
|
<ol>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/http-drivers.html#http-drivers">HTTP drivers</a>
|
|
|
|
|
|
<ol>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/javascript-bar.html#javascript-bar">Javascript Bar</a>
|
|
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
<a href="/docs/javascript-bar.html#tabs-and-indicators">Tabs and indicators</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/javascript-bar.html#data-mapping">Data mapping</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/javascript-bar.html#datasets">Datasets</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/javascript-bar.html#widgets">Widgets</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/javascript-bar.html#custom-tabs-and-indicators">Custom tabs and indicators</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
<a href="/docs/javascript-bar.html#openhandler">OpenHandler</a>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
</nav>
|
|
|
|
<nav id="links">
|
|
<ul>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
<a name="base-collectors"></a><h1>Base collectors</h1>
|
|
<p>Collectors provided in the <code>DebugBar\DataCollector</code> namespace.</p>
|
|
<a name="messages"></a><h2>Messages</h2>
|
|
<p>Provides a way to log messages (compatible with <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md">PSR-3 logger</a>).</p>
|
|
<pre><code>$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector());
|
|
$debugbar['messages']->info('hello world');</code></pre>
|
|
<p>You can have multiple messages collector by naming them:</p>
|
|
<pre><code>$debugbar->addCollector(new MessagesCollector('io_ops'));
|
|
$debugbar['io_ops']->info('opening files');</code></pre>
|
|
<p>You can aggregate messages collector into other to have a unified view:</p>
|
|
<pre><code>$debugbar['messages']->aggregate($debugbar['io_ops']);</code></pre>
|
|
<p>If you don't want to create a standalone tab in the debug bar but still be able
|
|
to log messages from a different collector, you don't have to add the collector
|
|
to the debug bar:</p>
|
|
<pre><code>$debugbar['messages']->aggregate(new MessagesCollector('io_ops'));</code></pre>
|
|
<a name="timedata"></a><h2>TimeData</h2>
|
|
<p>Provides a way to log total execution time as well as taking "measures" (ie. measure the execution time of a particular operation).</p>
|
|
<pre><code>$debugbar->addCollector(new DebugBar\DataCollector\TimeDataCollector());
|
|
|
|
$debugbar['time']->startMeasure('longop', 'My long operation');
|
|
sleep(2);
|
|
$debugbar['time']->stopMeasure('longop');
|
|
|
|
$debugbar['time']->measure('My long operation', function() {
|
|
sleep(2);
|
|
});</code></pre>
|
|
<p>Displays the measures on a timeline</p>
|
|
<a name="exceptions"></a><h2>Exceptions</h2>
|
|
<p>Display exceptions</p>
|
|
<pre><code>$debugbar->addCollector(new DebugBar\DataCollector\ExceptionsCollector());
|
|
|
|
try {
|
|
throw new Exception('foobar');
|
|
} catch (Exception $e) {
|
|
$debugbar['exceptions']->addException($e);
|
|
}</code></pre>
|
|
<a name="pdo"></a><h2>PDO</h2>
|
|
<p>Logs SQL queries. You need to wrap your <code>PDO</code> object into a <code>DebugBar\DataCollector\PDO\TraceablePDO</code> object.</p>
|
|
<pre><code>$pdo = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
|
|
$debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($pdo));</code></pre>
|
|
<p>You can even log queries from multiple <code>PDO</code> connections:</p>
|
|
<pre><code>$pdoRead = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
|
|
$pdoWrite = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
|
|
|
|
$pdoCollector = new DebugBar\DataCollector\PDO\PDOCollector();
|
|
$pdoCollector->addConnection($pdoRead, 'read-db');
|
|
$pdoCollector->addConnection($pdoWrite, 'write-db');
|
|
|
|
$debugbar->addCollector($pdoCollector);</code></pre>
|
|
<a name="requestdata"></a><h2>RequestData</h2>
|
|
<p>Collects the data of PHP's global variables</p>
|
|
<pre><code>$debugbar->addCollector(new DebugBar\DataCollector\RequestDataCollector());</code></pre>
|
|
<a name="config"></a><h2>Config</h2>
|
|
<p>Used to display any key/value pairs array</p>
|
|
<pre><code>$data = array('foo' => 'bar');
|
|
$debugbar->addCollector(new DebugBar\DataCollector\ConfigCollector($data));</code></pre>
|
|
<p>You can provide a different name for this collector in the second argument of the constructor.</p>
|
|
<a name="aggregatedcollector"></a><h2>AggregatedCollector</h2>
|
|
<p>Aggregates multiple collectors. Do not provide any widgets, you have to add your own controls.</p>
|
|
<pre><code>$debugbar->addCollector(new DebugBar\DataCollector\AggregatedCollector('all_messages', 'messages', 'time'));
|
|
$debugbar['all_messages']->addCollector($debugbar['messages']);
|
|
$debugbar['all_messages']->addCollector(new MessagesCollector('mails'));
|
|
$debugbar['all_messages']['mails']->addMessage('sending mail');
|
|
|
|
$renderer = $debugbar->getJavascriptRenderer();
|
|
$renderer->addControl('all_messages', array(
|
|
'widget' => 'PhpDebugBar.Widgets.MessagesWidget',
|
|
'map' => 'all_messages',
|
|
'default' => '[]';
|
|
));</code></pre>
|
|
<a name="others"></a><h2>Others</h2>
|
|
<p>Misc collectors which you can just register:</p>
|
|
<ul>
|
|
<li><code>MemoryCollector</code> (<em>memory</em>): Display memory usage</li>
|
|
<li><code>PhpInfoCollector</code> (<em>php</em>): PHP version number</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
<footer id="footer">
|
|
Powered by <a href="http://github.com/maximebf/beautiful-docs">beautiful-docs</a> -
|
|
<a href="#top">Back to top</a> - <a href="/docs/all.html">Everything on a single page</a>
|
|
- <a href="?print=1">Print current page</a> - <a href="/docs/all.html?print=1">Print all pages</a>
|
|
|
|
</footer>
|
|
</div>
|
|
</body>
|
|
</html>
|