Skip to content

Commit dda267e

Browse files
committed
updated docs and README
1 parent 63c88cc commit dda267e

File tree

5 files changed

+168
-90
lines changed

5 files changed

+168
-90
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,21 @@ No more `var_dump()` in your code!
1414
- Includes generic data collectors and collectors for well known libraries
1515
- The client side bar is 100% coded in javascript
1616
- Easily create your own collectors and their associated view in the bar
17+
- [Very well documented](http://phpdebugbar.com/docs)
1718

19+
Includes collectors for:
20+
21+
- [PDO](http://php.net/manual/en/book.pdo.php)
22+
- [CacheCache](http://maximebf.github.io/CacheCache/)
23+
- [Doctrine](http://doctrine-project.org)
24+
- [Monolog](https://github.com/Seldaek/monolog)
25+
- [Propel](http://propelorm.org/)
26+
- [Slim](http://slimframework.com)
27+
- [Swift Mailer](http://swiftmailer.org/)
28+
- [Twig](http://twig.sensiolabs.org/)
29+
30+
Checkout the [demo](https://github.com/maximebf/php-debugbar/tree/master/demo) for
31+
examples and [phpdebugbar.com](http://phpdebugbar.com) for a live example.
1832

1933
## Installation
2034

@@ -72,7 +86,7 @@ collector names. In our previous example, we add a message to the `MessagesColle
7286

7387
$debugbar["messages"]->addMessage("hello world!");
7488

75-
`StandardDebugBar` activates all bundled collectors:
89+
`StandardDebugBar` activates the following collectors:
7690

7791
- `MemoryCollector` (*memory*)
7892
- `MessagesCollector` (*messages*)

docs/base_collectors.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
# Base collectors
3+
4+
Collectors provided in the `DebugBar\DataCollector` namespace.
5+
6+
## Messages
7+
8+
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)).
9+
10+
$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector());
11+
$debugbar['messages']->info('hello world');
12+
13+
You can have multiple messages collector by naming them:
14+
15+
$debugbar->addCollector(new MessagesCollector('io_ops'));
16+
$debugbar['io_ops']->info('opening files');
17+
18+
You can aggregate messages collector into other to have a unified view:
19+
20+
$debugbar['messages']->aggregate($debugbar['io_ops']);
21+
22+
If you don't want to create a standalone tab in the debug bar but still be able
23+
to log messages from a different collector, you don't have to add the collector
24+
to the debug bar:
25+
26+
$debugbar['messages']->aggregate(new MessagesCollector('io_ops'));
27+
28+
## TimeData
29+
30+
Provides a way to log total execution time as well as taking "measures" (ie. measure the execution time of a particular operation).
31+
32+
$debugbar->addCollector(new DebugBar\DataCollector\TimeDataCollector());
33+
34+
$debugbar['time']->startMeasure('longop', 'My long operation');
35+
sleep(2);
36+
$debugbar['time']->stopMeasure('longop');
37+
38+
$debugbar['time']->measure('My long operation', function() {
39+
sleep(2);
40+
});
41+
42+
Displays the measures on a timeline
43+
44+
## Exceptions
45+
46+
Display exceptions
47+
48+
$debugbar->addCollector(new DebugBar\DataCollector\ExceptionsCollector());
49+
50+
try {
51+
throw new Exception('foobar');
52+
} catch (Exception $e) {
53+
$debugbar['exceptions']->addException($e);
54+
}
55+
56+
## PDO
57+
58+
Logs SQL queries. You need to wrap your `PDO` object into a `DebugBar\DataCollector\PDO\TraceablePDO` object.
59+
60+
$pdo = new DebugBar\DataCollector\PDO\TraceablePDO(new PDO('sqlite::memory:'));
61+
$debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($pdo));
62+
63+
## RequestDataCollector
64+
65+
Collects the data of PHP's global variables
66+
67+
$debugbar->addCollector(new DebugBar\DataCollector\RequestDataCollector());
68+
69+
## AggregatedCollector
70+
71+
Aggregates multiple collectors. Do not provide any widgets, you have to add your own controls.
72+
73+
$debugbar->addCollector(new DebugBar\DataCollector\AggregatedCollector('all_messages', 'messages', 'time'));
74+
$debugbar['all_messages']->addCollector($debugbar['messages']);
75+
$debugbar['all_messages']->addCollector(new MessagesCollector('mails'));
76+
$debugbar['all_messages']['mails']->addMessage('sending mail');
77+
78+
$renderer = $debugbar->getJavascriptRenderer();
79+
$renderer->addControl('all_messages', array(
80+
'widget' => 'PhpDebugBar.Widgets.MessagesWidget',
81+
'map' => 'all_messages',
82+
'default' => '[]';
83+
));
84+
85+
## Others
86+
87+
Misc collectors which you can just register:
88+
89+
- `MemoryCollector` (*memory*): Display memory usage
90+
- `PhpInfoCollector` (*php*): PHP version number

docs/bridge_collectors.md

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,40 @@
33
DebugBar comes with some "bridge" collectors. This collectors provides a way to integrate
44
other projets with the DebugBar.
55

6+
## CacheCache
7+
8+
http://maximebf.github.io/CacheCache/
9+
10+
Displays cache operations using `DebugBar\Bridge\CacheCacheCollector`
11+
12+
$cache = new CacheCache\Cache(new CacheCache\Backends\Memory());
13+
$debugbar->addCollector(new DebugBar\Bridge\CacheCacheCollector($cache));
14+
15+
CacheCache uses [Monolog](https://github.com/Seldaek/monolog) for logging,
16+
thus it is required to collect data.
17+
18+
`CacheCacheCollector` subclasses `MonologCollector`, thus it can be
19+
[aggregated in the messages view](base-collectors.html#messages).
20+
21+
## Doctrine
22+
23+
http://doctrine-project.org
24+
25+
Displays sql queries into an SQL queries view using `DebugBar\Bridge\DoctrineCollector`.
26+
You will need to set a `Doctrine\DBAL\Logging\DebugStack` logger on your connection.
27+
28+
$debugStack = new Doctrine\DBAL\Logging\DebugStack();
29+
$entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack);
30+
$debugbar->addCollector(new DebugBar\Bridge\DoctrineCollector($debugStack));
31+
32+
`DoctrineCollector` also accepts an `Doctrine\ORM\EntityManager` as argument
33+
provided the `SQLLogger` is a ̀DebugStack`.
34+
635
## Monolog
736

8-
Integrates Monolog messages into the messages view.
37+
https://github.com/Seldaek/monolog
38+
39+
Integrates Monolog messages into a message view using `DebugBar\Bridge\MonologCollector`.
940

1041
$logger = new Monolog\Logger('mylogger');
1142
$debugbar->addCollector(new DebugBar\Bridge\MonologCollector($logger));
@@ -14,10 +45,14 @@ Note that multiple logger can be collected:
1445

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

48+
`MonologCollector` can be [aggregated](base-collectors.html#messages) into the `MessagesCollector`.
49+
1750
## Propel
1851

19-
Logs propel queries into an SQL queries view. You will need to activate
20-
Propel debug mode.
52+
http://propelorm.org/
53+
54+
Displays propel queries into an SQL queries view using `DebugBar\Bridge\PropelCollector`.
55+
You will need to activate Propel debug mode.
2156

2257
// before Propel::init()
2358
$debugbar->addCollector(new DebugBar\Bridge\PropelCollector());
@@ -31,10 +66,32 @@ Propel debug mode.
3166
Queries can be collected on a single connection by providing the `PropelPDO` object
3267
to the `PropelCollector` as first argument.
3368

69+
## Slim
70+
71+
http://slimframework.com
72+
73+
Displays message from the Slim logger into a message view using `DebugBar\Bridge\SlimCollector`.
74+
75+
$app = new Slim\Slim();
76+
$debugbar->addCollector(new DebugBar\Bridge\SlimCollector($app));
77+
78+
## Swift Mailer
79+
80+
http://swiftmailer.org/
81+
82+
Display log messages and sent mail using `DebugBar\Bridge\SwiftMailer\SwiftLogCollector` and
83+
`DebugBar\Bridge\SwiftMailer\SwiftMailCollector`.
84+
85+
$mailer = Swift_Mailer::newInstance(Swift_NullTransport::newInstance());
86+
$debugbar['messages']->aggregate(new DebugBar\Bridge\SwiftMailer\SwiftLogCollector($mailer));
87+
$debugbar->addCollector(new DebugBar\Bridge\SwiftMailer\SwiftMailCollector($mailer));
88+
3489
## Twig
3590

36-
Collects info about rendered templates. You need to wrap your `Twig_Environment` object
37-
into a `DebugBar\Bridge\Twig\TraceableTwigEnvironment` object.
91+
http://twig.sensiolabs.org/
92+
93+
Collects info about rendered templates using `DebugBar\Bridge\Twig\TwigCollector`.
94+
You need to wrap your `Twig_Environment` object into a `DebugBar\Bridge\Twig\TraceableTwigEnvironment` object.
3895

3996
$loader = new Twig_Loader_Filesystem('.');
4097
$env = new DebugBar\Bridge\Twig\TraceableTwigEnvironment(new Twig_Environment($loader));

docs/data_collectors.md

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -70,87 +70,3 @@ in `JavascriptRenderer::addControl($name, $options)` (see Rendering chapter).
7070
}
7171

7272
This will have the result of adding a new indicator to the debug bar.
73-
74-
## Base collectors
75-
76-
Cpllectors provided in the `DebugBar\DataCollector` namespace.
77-
78-
### Messages
79-
80-
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)).
81-
82-
$debugbar->addCollector(new MessagesCollector());
83-
$debugbar['messages']->info('hello world');
84-
85-
You can have multiple messages collector by naming them:
86-
87-
$debugbar->addCollector(new MessagesCollector('io_ops'));
88-
$debugbar['io_ops']->info('opening files');
89-
90-
You can aggregate messages collector into other to have a unified view:
91-
92-
$debugbar['messages']->aggregate($debugbar['io_ops']);
93-
94-
### TimeData
95-
96-
Provides a way to log total execution time as well as taking "measures" (ie. measure the execution time of a particular operation).
97-
98-
$debugbar->addCollector(new TimeDataCollector());
99-
100-
$debugbar['time']->startMeasure('longop', 'My long operation');
101-
sleep(2);
102-
$debugbar['time']->stopMeasure('longop');
103-
104-
$debugbar['time']->measure('My long operation', function() {
105-
sleep(2);
106-
});
107-
108-
Displays the measures on a timeline
109-
110-
### Exceptions
111-
112-
Display exceptions
113-
114-
$debugbar->addCollector(new ExceptionsCollector());
115-
116-
try {
117-
throw new Exception('foobar');
118-
} catch (Exception $e) {
119-
$debugbar['exceptions']->addException($e);
120-
}
121-
122-
### PDO
123-
124-
Logs SQL queries. You need to wrap your `PDO` object into a `DebugBar\DataCollector\PDO\TraceablePDO` object.
125-
126-
$pdo = new PDO\TraceablePDO(new PDO('sqlite::memory:'));
127-
$debugbar->addCollector(new PDO\PDOCollector($pdo));
128-
129-
### RequestDataCollector
130-
131-
Collects the data of PHP's global variables
132-
133-
$debugbar->addCollector(new RequestDataCollector());
134-
135-
### AggregatedCollector
136-
137-
Aggregates multiple collectors. Do not provide any widgets, you have to add your own controls.
138-
139-
$debugbar->addCollector(new AggregatedCollector('all_messages', 'messages', 'time'));
140-
$debugbar['all_messages']->addCollector($debugbar['messages']);
141-
$debugbar['all_messages']->addCollector(new MessagesCollector('mails'));
142-
$debugbar['all_messages']['mails']->addMessage('sending mail');
143-
144-
$renderer = $debugbar->getJavascriptRenderer();
145-
$renderer->addControl('all_messages', array(
146-
'widget' => 'PhpDebugBar.Widgets.MessagesWidget',
147-
'map' => 'all_messages',
148-
'default' => '[]';
149-
));
150-
151-
### Others
152-
153-
Misc collectors which you can just register:
154-
155-
- `MemoryCollector` (*memory*): Display memory usage
156-
- `PhpInfoCollector` (*php*): PHP version number

docs/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"data_collectors.md",
88
"rendering.md",
99
"javascript_bar.md",
10+
"base_collectors.md",
1011
"bridge_collectors.md"
1112
]
1213
}

0 commit comments

Comments
 (0)