Skip to content

Commit 3759f08

Browse files
committed
Merge pull request #226 from sdebacker/patch-1
Code blocks with syntax highlighting + small typo
2 parents a3b1f74 + e050190 commit 3759f08

File tree

1 file changed

+73
-45
lines changed

1 file changed

+73
-45
lines changed

readme.md

Lines changed: 73 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,82 +41,104 @@ It also provides a Facade interface for easy logging Messages, Exceptions and Ti
4141

4242
Require this package with composer:
4343

44-
composer require barryvdh/laravel-debugbar
44+
```
45+
composer require barryvdh/laravel-debugbar
46+
```
4547

4648
After updating composer, add the ServiceProvider to the providers array in app/config/app.php
4749

48-
'Barryvdh\Debugbar\ServiceProvider',
49-
50+
```
51+
'Barryvdh\Debugbar\ServiceProvider',
52+
```
53+
5054
If you want to use the facade to log messages, add this to your facades in app.php:
5155

52-
'Debugbar' => 'Barryvdh\Debugbar\Facade',
56+
```
57+
'Debugbar' => 'Barryvdh\Debugbar\Facade',
58+
```
5359

5460
~~You need to publish the assets from this package.~~ Since 1.7, you don't need to publish the assets anymore.
5561

5662
The profiler is enabled by default, if you have app.debug=true. You can override that in the config files.
5763
You can also set in your config if you want to include/exclude the vendor files also (FontAwesome, Highlight.js and jQuery). If you already use them in your site, set it to false.
5864
You can also only display the js of css vendors, by setting it to 'js' or 'css'. (Highlight.js requires both css + js, so set to `true` for syntax highlighting)
5965

60-
php artisan config:publish barryvdh/laravel-debugbar
66+
```
67+
php artisan config:publish barryvdh/laravel-debugbar
68+
```
6169

6270
You can also disable/enable the loggers you want. You can also use the IoC container to add extra loggers. (`$app['debugbar']->addCollector(new MyDataCollector)`)
6371

6472
You can now add messages using the Facade (when added), using the PSR-3 levels (debug, info, notice, warning, error, critical, alert, emergency):
6573

66-
Debugbar::info($object);
67-
Debugbar::error("Error!");
68-
Debugbar::warning('Watch out..');
69-
Debugbar::addMessage('Another message', 'mylabel');
74+
```php
75+
Debugbar::info($object);
76+
Debugbar::error('Error!');
77+
Debugbar::warning('Watch out…');
78+
Debugbar::addMessage('Another message', 'mylabel');
79+
```
7080

7181
And start/stop timing:
7282

73-
Debugbar::startMeasure('render','Time for rendering');
74-
Debugbar::stopMeasure('render');
75-
Debugbar::addMeasure('now', LARAVEL_START, microtime(true));
76-
Debugbar::measure('My long operation', function() {
77-
//Do something..
78-
});
83+
```php
84+
Debugbar::startMeasure('render','Time for rendering');
85+
Debugbar::stopMeasure('render');
86+
Debugbar::addMeasure('now', LARAVEL_START, microtime(true));
87+
Debugbar::measure('My long operation', function() {
88+
// Do something…
89+
});
90+
```
7991

8092
Or log exceptions:
8193

82-
try {
83-
throw new Exception('foobar');
84-
} catch (Exception $e) {
85-
Debugbar::addException($e);
86-
}
87-
94+
```php
95+
try {
96+
throw new Exception('foobar');
97+
} catch (Exception $e) {
98+
Debugbar::addException($e);
99+
}
100+
```
101+
88102
There are also helper functions available for the most common calls:
89103

90-
// All arguments will be dumped as a debug message
91-
debug($var1, $someString, $intValue, $object);
92-
93-
start_measure('render','Time for rendering');
94-
stop_measure('render');
95-
add_measure('now', LARAVEL_START, microtime(true));
96-
measure('My long operation', function() {
97-
//Do something..
98-
});
104+
```php
105+
// All arguments will be dumped as a debug message
106+
debug($var1, $someString, $intValue, $object);
107+
108+
start_measure('render','Time for rendering');
109+
stop_measure('render');
110+
add_measure('now', LARAVEL_START, microtime(true));
111+
measure('My long operation', function() {
112+
// Do something…
113+
});
114+
```
99115

100116
If you want you can add your own DataCollectors, through the Container or the Facade:
101117

102-
Debugbar::addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages'));
103-
//Or via the App container:
104-
$debugbar = App::make('debugbar');
105-
$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages'));
118+
```php
119+
Debugbar::addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages'));
120+
//Or via the App container:
121+
$debugbar = App::make('debugbar');
122+
$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages'));
123+
```
106124

107125
By default, the Debugbar is injected just before `</body>`. If you want to inject the Debugbar yourself,
108126
set the config option 'inject' to false and use the renderer yourself and follow http://phpdebugbar.com/docs/rendering.html
109127

110-
$renderer = Debugbar::getJavascriptRenderer();
128+
```php
129+
$renderer = Debugbar::getJavascriptRenderer();
130+
```
111131

112132
Note: Not using the auto-inject, will disable the Request information, because that is added After the response.
113133
You can add the default_request datacollector in the config as alternative.
114134

115135
## Enabling/Disabling on run time
116136
You can enable or disable the debugbar during run time.
117137

118-
\Debugbar::enable();
119-
\Debugbar::disable();
138+
```php
139+
\Debugbar::enable();
140+
\Debugbar::disable();
141+
```
120142

121143
NB. Once enabled, the collectors are added (and could produce extra overhead), so if you want to use the debugbar in production, disable in the config and only enable when needed.
122144

@@ -127,18 +149,24 @@ Laravel Debugbar comes with two Twig Extensions. These are tested with [rcrowe/T
127149

128150
Add the following extensions to your TwigBridge config/extensions.php (or register the extensions manually)
129151

130-
'Barryvdh\Debugbar\Twig\Extension\Debug',
131-
'Barryvdh\Debugbar\Twig\Extension\Dump',
132-
'Barryvdh\Debugbar\Twig\Extension\Stopwatch',
152+
```php
153+
'Barryvdh\Debugbar\Twig\Extension\Debug',
154+
'Barryvdh\Debugbar\Twig\Extension\Dump',
155+
'Barryvdh\Debugbar\Twig\Extension\Stopwatch',
156+
```
133157

134158
The Dump extension will replace the [dump function](http://twig.sensiolabs.org/doc/functions/dump.html) to output variables using the DataFormatter. The Debug extension adds a `debug()` function which passes variables to the Message Collector,
135159
instead of showing it directly in the template. It dumps the arguments, or when empty; all context variables.
136160

137-
{{ debug() }}
138-
{{ debug(user, categories) }}
161+
```
162+
{{ debug() }}
163+
{{ debug(user, categories) }}
164+
```
139165

140166
The Stopwatch extension adds a [stopwatch tag](http://symfony.com/blog/new-in-symfony-2-4-a-stopwatch-tag-for-twig) similar to the one in Symfony/Silex Twigbridge.
141167

142-
{% stopwatch "foo" %}
143-
... some things that gets timed
144-
{% endstopwatch %}
168+
```
169+
{% stopwatch "foo" %}
170+
…some things that gets timed
171+
{% endstopwatch %}
172+
```

0 commit comments

Comments
 (0)