mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-01-17 05:18:32 +01:00
updated docs and README
This commit is contained in:
parent
63c88cc67e
commit
dda267ebd1
16
README.md
16
README.md
@ -14,7 +14,21 @@ No more `var_dump()` in your code!
|
||||
- Includes generic data collectors and collectors for well known libraries
|
||||
- The client side bar is 100% coded in javascript
|
||||
- Easily create your own collectors and their associated view in the bar
|
||||
- [Very well documented](http://phpdebugbar.com/docs)
|
||||
|
||||
Includes collectors for:
|
||||
|
||||
- [PDO](http://php.net/manual/en/book.pdo.php)
|
||||
- [CacheCache](http://maximebf.github.io/CacheCache/)
|
||||
- [Doctrine](http://doctrine-project.org)
|
||||
- [Monolog](https://github.com/Seldaek/monolog)
|
||||
- [Propel](http://propelorm.org/)
|
||||
- [Slim](http://slimframework.com)
|
||||
- [Swift Mailer](http://swiftmailer.org/)
|
||||
- [Twig](http://twig.sensiolabs.org/)
|
||||
|
||||
Checkout the [demo](https://github.com/maximebf/php-debugbar/tree/master/demo) for
|
||||
examples and [phpdebugbar.com](http://phpdebugbar.com) for a live example.
|
||||
|
||||
## Installation
|
||||
|
||||
@ -72,7 +86,7 @@ collector names. In our previous example, we add a message to the `MessagesColle
|
||||
|
||||
$debugbar["messages"]->addMessage("hello world!");
|
||||
|
||||
`StandardDebugBar` activates all bundled collectors:
|
||||
`StandardDebugBar` activates the following collectors:
|
||||
|
||||
- `MemoryCollector` (*memory*)
|
||||
- `MessagesCollector` (*messages*)
|
||||
|
90
docs/base_collectors.md
Normal file
90
docs/base_collectors.md
Normal file
@ -0,0 +1,90 @@
|
||||
|
||||
# Base collectors
|
||||
|
||||
Collectors provided in the `DebugBar\DataCollector` namespace.
|
||||
|
||||
## Messages
|
||||
|
||||
Provides a way to log messages (compotible with [PSR-3 logger](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)).
|
||||
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector());
|
||||
$debugbar['messages']->info('hello world');
|
||||
|
||||
You can have multiple messages collector by naming them:
|
||||
|
||||
$debugbar->addCollector(new MessagesCollector('io_ops'));
|
||||
$debugbar['io_ops']->info('opening files');
|
||||
|
||||
You can aggregate messages collector into other to have a unified view:
|
||||
|
||||
$debugbar['messages']->aggregate($debugbar['io_ops']);
|
||||
|
||||
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:
|
||||
|
||||
$debugbar['messages']->aggregate(new MessagesCollector('io_ops'));
|
||||
|
||||
## TimeData
|
||||
|
||||
Provides a way to log total execution time as well as taking "measures" (ie. measure the execution time of a particular operation).
|
||||
|
||||
$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);
|
||||
});
|
||||
|
||||
Displays the measures on a timeline
|
||||
|
||||
## Exceptions
|
||||
|
||||
Display exceptions
|
||||
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\ExceptionsCollector());
|
||||
|
||||
try {
|
||||
throw new Exception('foobar');
|
||||
} catch (Exception $e) {
|
||||
$debugbar['exceptions']->addException($e);
|
||||
}
|
||||
|
||||
## PDO
|
||||
|
||||
Logs SQL queries. You need to wrap your `PDO` object into a `DebugBar\DataCollector\PDO\TraceablePDO` object.
|
||||
|
||||
$pdo = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($pdo));
|
||||
|
||||
## RequestDataCollector
|
||||
|
||||
Collects the data of PHP's global variables
|
||||
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\RequestDataCollector());
|
||||
|
||||
## AggregatedCollector
|
||||
|
||||
Aggregates multiple collectors. Do not provide any widgets, you have to add your own controls.
|
||||
|
||||
$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' => '[]';
|
||||
));
|
||||
|
||||
## Others
|
||||
|
||||
Misc collectors which you can just register:
|
||||
|
||||
- `MemoryCollector` (*memory*): Display memory usage
|
||||
- `PhpInfoCollector` (*php*): PHP version number
|
@ -3,9 +3,40 @@
|
||||
DebugBar comes with some "bridge" collectors. This collectors provides a way to integrate
|
||||
other projets with the DebugBar.
|
||||
|
||||
## 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));
|
||||
|
||||
CacheCache uses [Monolog](https://github.com/Seldaek/monolog) for logging,
|
||||
thus it is required to collect data.
|
||||
|
||||
`CacheCacheCollector` subclasses `MonologCollector`, thus it can be
|
||||
[aggregated in the messages view](base-collectors.html#messages).
|
||||
|
||||
## Doctrine
|
||||
|
||||
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));
|
||||
|
||||
`DoctrineCollector` also accepts an `Doctrine\ORM\EntityManager` as argument
|
||||
provided the `SQLLogger` is a ̀DebugStack`.
|
||||
|
||||
## Monolog
|
||||
|
||||
Integrates Monolog messages into the messages view.
|
||||
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));
|
||||
@ -14,10 +45,14 @@ Note that multiple logger can be collected:
|
||||
|
||||
$debugbar['monolog']->addLogger($logger);
|
||||
|
||||
`MonologCollector` can be [aggregated](base-collectors.html#messages) into the `MessagesCollector`.
|
||||
|
||||
## Propel
|
||||
|
||||
Logs propel queries into an SQL queries view. You will need to activate
|
||||
Propel debug mode.
|
||||
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());
|
||||
@ -31,10 +66,32 @@ Propel debug mode.
|
||||
Queries can be collected on a single connection by providing the `PropelPDO` object
|
||||
to the `PropelCollector` as first argument.
|
||||
|
||||
## 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));
|
||||
|
||||
## Twig
|
||||
|
||||
Collects info about rendered templates. You need to wrap your `Twig_Environment` object
|
||||
into a `DebugBar\Bridge\Twig\TraceableTwigEnvironment` object.
|
||||
http://twig.sensiolabs.org/
|
||||
|
||||
Collects info about rendered templates using `DebugBar\Bridge\Twig\TwigCollector`.
|
||||
You need to wrap your `Twig_Environment` object into a `DebugBar\Bridge\Twig\TraceableTwigEnvironment` object.
|
||||
|
||||
$loader = new Twig_Loader_Filesystem('.');
|
||||
$env = new DebugBar\Bridge\Twig\TraceableTwigEnvironment(new Twig_Environment($loader));
|
||||
|
@ -70,87 +70,3 @@ in `JavascriptRenderer::addControl($name, $options)` (see Rendering chapter).
|
||||
}
|
||||
|
||||
This will have the result of adding a new indicator to the debug bar.
|
||||
|
||||
## Base collectors
|
||||
|
||||
Cpllectors provided in the `DebugBar\DataCollector` namespace.
|
||||
|
||||
### Messages
|
||||
|
||||
Provides a way to log messages (compotible with [PSR-3 logger](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)).
|
||||
|
||||
$debugbar->addCollector(new MessagesCollector());
|
||||
$debugbar['messages']->info('hello world');
|
||||
|
||||
You can have multiple messages collector by naming them:
|
||||
|
||||
$debugbar->addCollector(new MessagesCollector('io_ops'));
|
||||
$debugbar['io_ops']->info('opening files');
|
||||
|
||||
You can aggregate messages collector into other to have a unified view:
|
||||
|
||||
$debugbar['messages']->aggregate($debugbar['io_ops']);
|
||||
|
||||
### TimeData
|
||||
|
||||
Provides a way to log total execution time as well as taking "measures" (ie. measure the execution time of a particular operation).
|
||||
|
||||
$debugbar->addCollector(new TimeDataCollector());
|
||||
|
||||
$debugbar['time']->startMeasure('longop', 'My long operation');
|
||||
sleep(2);
|
||||
$debugbar['time']->stopMeasure('longop');
|
||||
|
||||
$debugbar['time']->measure('My long operation', function() {
|
||||
sleep(2);
|
||||
});
|
||||
|
||||
Displays the measures on a timeline
|
||||
|
||||
### Exceptions
|
||||
|
||||
Display exceptions
|
||||
|
||||
$debugbar->addCollector(new ExceptionsCollector());
|
||||
|
||||
try {
|
||||
throw new Exception('foobar');
|
||||
} catch (Exception $e) {
|
||||
$debugbar['exceptions']->addException($e);
|
||||
}
|
||||
|
||||
### PDO
|
||||
|
||||
Logs SQL queries. You need to wrap your `PDO` object into a `DebugBar\DataCollector\PDO\TraceablePDO` object.
|
||||
|
||||
$pdo = new PDO\TraceablePDO(new PDO('sqlite::memory:'));
|
||||
$debugbar->addCollector(new PDO\PDOCollector($pdo));
|
||||
|
||||
### RequestDataCollector
|
||||
|
||||
Collects the data of PHP's global variables
|
||||
|
||||
$debugbar->addCollector(new RequestDataCollector());
|
||||
|
||||
### AggregatedCollector
|
||||
|
||||
Aggregates multiple collectors. Do not provide any widgets, you have to add your own controls.
|
||||
|
||||
$debugbar->addCollector(new 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' => '[]';
|
||||
));
|
||||
|
||||
### Others
|
||||
|
||||
Misc collectors which you can just register:
|
||||
|
||||
- `MemoryCollector` (*memory*): Display memory usage
|
||||
- `PhpInfoCollector` (*php*): PHP version number
|
||||
|
@ -7,6 +7,7 @@
|
||||
"data_collectors.md",
|
||||
"rendering.md",
|
||||
"javascript_bar.md",
|
||||
"base_collectors.md",
|
||||
"bridge_collectors.md"
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user