1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-02-06 07:49:05 +01:00
php-debugbar/docs/bridge_collectors.md

102 lines
3.5 KiB
Markdown
Raw Normal View History

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