1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-06-09 15:45:25 +02:00
php-debugbar/docs/bridge-collectors.html
Barry vd. Heuvel d07c5fc73a Add canonical
2025-02-13 20:23:44 +01:00

416 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/bridge/" />
<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="bridge-collectors"></a><h1>Bridge collectors</h1>
<p>DebugBar comes with some &quot;bridge&quot; collectors. This collectors provides a way to integrate
other projects with the DebugBar.</p>
<a name="cachecache"></a><h2>CacheCache</h2>
<p><a href="http://maximebf.github.io/CacheCache/">http://maximebf.github.io/CacheCache/</a></p>
<p>Displays cache operations using <code>DebugBar\Bridge\CacheCacheCollector</code></p>
<pre><code>$cache = new CacheCache\Cache(new CacheCache\Backends\Memory());
$debugbar-&gt;addCollector(new DebugBar\Bridge\CacheCacheCollector($cache));</code></pre>
<p>CacheCache uses <a href="https://github.com/Seldaek/monolog">Monolog</a> for logging,
thus it is required to collect data.</p>
<p><code>CacheCacheCollector</code> subclasses <code>MonologCollector</code>, thus it can be
<a href="base-collectors.html#messages">aggregated in the messages view</a>.</p>
<a name="doctrine"></a><h2>Doctrine</h2>
<p><a href="http://doctrine-project.org">http://doctrine-project.org</a></p>
<p>Displays sql queries into an SQL queries view using <code>DebugBar\Bridge\DoctrineCollector</code>.
You will need to set a <code>Doctrine\DBAL\Logging\DebugStack</code> logger on your connection.</p>
<pre><code>$debugStack = new Doctrine\DBAL\Logging\DebugStack();
$entityManager-&gt;getConnection()-&gt;getConfiguration()-&gt;setSQLLogger($debugStack);
$debugbar-&gt;addCollector(new DebugBar\Bridge\DoctrineCollector($debugStack));</code></pre>
<p><code>DoctrineCollector</code> also accepts an <code>Doctrine\ORM\EntityManager</code> as argument
provided the <code>SQLLogger</code> is a ̀DebugStack`.</p>
<a name="monolog"></a><h2>Monolog</h2>
<p><a href="https://github.com/Seldaek/monolog">https://github.com/Seldaek/monolog</a></p>
<p>Integrates Monolog messages into a message view using <code>DebugBar\Bridge\MonologCollector</code>.</p>
<pre><code>$logger = new Monolog\Logger(&#39;mylogger&#39;);
$debugbar-&gt;addCollector(new DebugBar\Bridge\MonologCollector($logger));</code></pre>
<p>Note that multiple logger can be collected:</p>
<pre><code>$debugbar[&#39;monolog&#39;]-&gt;addLogger($logger);</code></pre>
<p><code>MonologCollector</code> can be <a href="base-collectors.html#messages">aggregated</a> into the <code>MessagesCollector</code>.</p>
<a name="propel"></a><h2>Propel</h2>
<p><a href="http://propelorm.org/">http://propelorm.org/</a></p>
<p>Displays propel queries into an SQL queries view using <code>DebugBar\Bridge\PropelCollector</code>.
You will need to activate Propel debug mode.</p>
<pre><code>// before Propel::init()
$debugbar-&gt;addCollector(new DebugBar\Bridge\PropelCollector());
Propel::init(&#39;/path/to/config&#39;);
// after Propel::init()
// not mandatory if you set config options by yourself
DebugBar\Bridge\PropelCollector::enablePropelProfiling();</code></pre>
<p>Queries can be collected on a single connection by providing the <code>PropelPDO</code> object
to the <code>PropelCollector</code> as first argument.</p>
<a name="slim"></a><h2>Slim</h2>
<p><a href="http://slimframework.com">http://slimframework.com</a></p>
<p>Displays message from the Slim logger into a message view using <code>DebugBar\Bridge\SlimCollector</code>.</p>
<pre><code>$app = new Slim\Slim();
$debugbar-&gt;addCollector(new DebugBar\Bridge\SlimCollector($app));</code></pre>
<a name="swift-mailer"></a><h2>Swift Mailer</h2>
<p><a href="http://swiftmailer.org/">http://swiftmailer.org/</a></p>
<p>Display log messages and sent mail using <code>DebugBar\Bridge\SwiftMailer\SwiftLogCollector</code> and
<code>DebugBar\Bridge\SwiftMailer\SwiftMailCollector</code>.</p>
<pre><code>$mailer = Swift_Mailer::newInstance(Swift_NullTransport::newInstance());
$debugbar[&#39;messages&#39;]-&gt;aggregate(new DebugBar\Bridge\SwiftMailer\SwiftLogCollector($mailer));
$debugbar-&gt;addCollector(new DebugBar\Bridge\SwiftMailer\SwiftMailCollector($mailer));</code></pre>
<a name="twig"></a><h2>Twig</h2>
<p><a href="http://twig.sensiolabs.org/">http://twig.sensiolabs.org/</a></p>
<p>Collects info about rendered templates using <code>DebugBar\Bridge\Twig\TwigCollector</code>.
You need to wrap your <code>Twig_Environment</code> object into a <code>DebugBar\Bridge\Twig\TraceableTwigEnvironment</code> object.</p>
<pre><code>$loader = new Twig_Loader_Filesystem(&#39;.&#39;);
$env = new DebugBar\Bridge\Twig\TraceableTwigEnvironment(new Twig_Environment($loader));
$debugbar-&gt;addCollector(new DebugBar\Bridge\Twig\TwigCollector($env));</code></pre>
<p>You can provide a <code>DebugBar\DataCollector\TimeDataCollector</code> as the second argument of
<code>TraceableTwigEnvironment</code> so render operation can be measured.</p>
</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>