Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 41 additions & 30 deletions docs/collectors/bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ 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));

```php
$cache = new CacheCache\Cache(new CacheCache\Backends\Memory());
$debugbar->addCollector(new DebugBar\Bridge\CacheCacheCollector($cache));
```
CacheCache uses [Monolog](https://github.com/Seldaek/monolog) for logging,
thus it is required to collect data.

Expand All @@ -25,10 +26,11 @@ http://doctrine-project.org
Displays sql queries into an SQL queries view using `DebugBar\Bridge\DoctrineCollector`.
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));

```php
$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`.

Expand All @@ -38,13 +40,15 @@ https://github.com/Seldaek/monolog

Integrates Monolog messages into a message view using `DebugBar\Bridge\MonologCollector`.

$logger = new Monolog\Logger('mylogger');
$debugbar->addCollector(new DebugBar\Bridge\MonologCollector($logger));

```php
$logger = new Monolog\Logger('mylogger');
$debugbar->addCollector(new DebugBar\Bridge\MonologCollector($logger));
```
Note that multiple logger can be collected:

$debugbar['monolog']->addLogger($logger);

```php
$debugbar['monolog']->addLogger($logger);
```
`MonologCollector` can be [aggregated](base.md#messages) into the `MessagesCollector`.

## Propel
Expand All @@ -54,14 +58,16 @@ http://propelorm.org/
Displays propel queries into an SQL queries view using `DebugBar\Bridge\PropelCollector`.
You will need to activate Propel debug mode.

// before Propel::init()
$debugbar->addCollector(new DebugBar\Bridge\PropelCollector());
```php
// before Propel::init()
$debugbar->addCollector(new DebugBar\Bridge\PropelCollector());

Propel::init('/path/to/config');
Propel::init('/path/to/config');

// after Propel::init()
// not mandatory if you set config options by yourself
DebugBar\Bridge\PropelCollector::enablePropelProfiling();
// 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.
Expand All @@ -72,8 +78,10 @@ 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));
```php
$app = new Slim\Slim();
$debugbar->addCollector(new DebugBar\Bridge\SlimCollector($app));
```

## Swift Mailer

Expand All @@ -82,23 +90,27 @@ 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));
```php
$mailer = Swift_Mailer::newInstance(Swift_NullTransport::newInstance());
$debugbar['messages']->aggregate(new DebugBar\Bridge\SwiftMailer\SwiftLogCollector($mailer));
$debugbar->addCollector(new DebugBar\Bridge\SwiftMailer\SwiftMailCollector($mailer));
```

## Symfony Mailer

https://symfony.com/doc/current/mailer.html

Display log messages and sent mail using `DebugBar\Bridge\Symfony\SymfonyMailCollector`

use Symfony\Component\Mailer\Event\SentMessageEvent;
```php
use Symfony\Component\Mailer\Event\SentMessageEvent;

$mailCollector = new DebugBar\Bridge\Symfony\SymfonyMailCollector();
$debugbar->addCollector($mailCollector);
$eventDispatcher->addListener(SentMessageEvent::class, function (SentMessageEvent $event) use (&$mailCollector): void {
$mailCollector->addSymfonyMessage($event->getMessage());
});
$mailCollector = new DebugBar\Bridge\Symfony\SymfonyMailCollector();
$debugbar->addCollector($mailCollector);
$eventDispatcher->addListener(SentMessageEvent::class, function (SentMessageEvent $event) use (&$mailCollector): void {
$mailCollector->addSymfonyMessage($event->getMessage());
});
```

## Twig

Expand Down Expand Up @@ -183,4 +195,3 @@ $twig->addExtension(new DebugBar\Bridge\Twig\DebugTwigExtension($debugbar['messa

$debugbar->addCollector(new DebugBar\Bridge\TwigProfileCollector($profile));
```