|
1 | | -## Laravel Debugbar |
2 | | -[](http://choosealicense.com/licenses/mit/) |
3 | | -[](https://packagist.org/packages/barryvdh/laravel-debugbar) |
4 | | -[](https://packagist.org/packages/barryvdh/laravel-debugbar) |
5 | | - |
6 | | -### For Laravel 4, please use the [1.8 branch](https://github.com/barryvdh/laravel-debugbar/tree/1.8)! |
7 | | - |
8 | | -This is a package to integrate [PHP Debug Bar](http://phpdebugbar.com/) with Laravel 5. |
9 | | -It includes a ServiceProvider to register the debugbar and attach it to the output. You can publish assets and configure it through Laravel. |
10 | | -It bootstraps some Collectors to work with Laravel and implements a couple custom DataCollectors, specific for Laravel. |
11 | | -It is configured to display Redirects and (jQuery) Ajax Requests. (Shown in a dropdown) |
12 | | -Read [the documentation](http://phpdebugbar.com/docs/) for more configuration options. |
13 | | - |
14 | | - |
15 | | - |
16 | | -Note: Use the DebugBar only in development. It can slow the application down (because it has to gather data). So when experiencing slowness, try disabling some of the collectors. |
17 | | - |
18 | | -This package includes some custom collectors: |
19 | | - - QueryCollector: Show all queries, including binding + timing |
20 | | - - RouteCollector: Show information about the current Route. |
21 | | - - ViewCollector: Show the currently loaded views. (Optionally: display the shared data) |
22 | | - - EventsCollector: Show all events |
23 | | - - LaravelCollector: Show the Laravel version and Environment. (disabled by default) |
24 | | - - SymfonyRequestCollector: replaces the RequestCollector with more information about the request/response |
25 | | - - LogsCollector: Show the latest log entries from the storage logs. (disabled by default) |
26 | | - - FilesCollector: Show the files that are included/required by PHP. (disabled by default) |
27 | | - - ConfigCollector: Display the values from the config files. (disabled by default) |
28 | | - |
29 | | -Bootstraps the following collectors for Laravel: |
30 | | - - LogCollector: Show all Log messages |
31 | | - - SwiftMailCollector and SwiftLogCollector for Mail |
32 | | - |
33 | | -And the default collectors: |
34 | | - - PhpInfoCollector |
35 | | - - MessagesCollector |
36 | | - - TimeDataCollector (With Booting and Application timing) |
37 | | - - MemoryCollector |
38 | | - - ExceptionsCollector |
39 | | - |
40 | | -It also provides a Facade interface for easy logging Messages, Exceptions and Time |
| 1 | +# Laravel Api Tester |
41 | 2 |
|
42 | 3 | ## Installation |
43 | 4 |
|
44 | 5 | Require this package with composer: |
45 | 6 |
|
46 | 7 | ``` |
47 | | -composer require barryvdh/laravel-debugbar |
| 8 | +composer require asvae/laravel-api-tester |
48 | 9 | ``` |
49 | 10 |
|
50 | 11 | After updating composer, add the ServiceProvider to the providers array in config/app.php |
51 | | -> If you use a catch-all/fallback route, make sure you load the Debugbar ServiceProvider before your own App ServiceProviders. |
52 | | -
|
53 | | -### Laravel 5.x: |
54 | | - |
55 | | -``` |
56 | | -Asvae\ApiTester\\ServiceProvider::class, |
57 | | -``` |
58 | | - |
59 | | -If you want to use the facade to log messages, add this to your facades in app.php: |
60 | | - |
61 | | -``` |
62 | | -'Debugbar' => Barryvdh\Debugbar\Facade::class, |
63 | | -``` |
64 | | - |
65 | | - |
66 | | -The profiler is enabled by default, if you have app.debug=true. You can override that in the config (`debugbar.enabled`). See more options in `config/debugbar.php` |
67 | | -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. |
68 | | -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) |
69 | | - |
70 | | -Copy the package config to your local config with the publish command: |
71 | | - |
72 | | -``` |
73 | | -php artisan vendor:publish |
74 | | -``` |
75 | | - |
76 | | -### Lumen: |
77 | | - |
78 | | -For Lumen, register a different Provider in `bootstrap/app.php`: |
79 | | - |
80 | | -``` |
81 | | -if (env('APP_DEBUG')) { |
82 | | - $app->register(Barryvdh\Debugbar\LumenServiceProvider::class); |
83 | | -} |
84 | | -``` |
85 | | - |
86 | | -To change the configuration, copy the file to your config folder and enable it: |
87 | | - |
88 | | -``` |
89 | | -$app->configure('debugbar'); |
90 | | -``` |
91 | | - |
92 | | -## Usage |
93 | | - |
94 | | -You can now add messages using the Facade (when added), using the PSR-3 levels (debug, info, notice, warning, error, critical, alert, emergency): |
95 | | - |
96 | | -```php |
97 | | -Debugbar::info($object); |
98 | | -Debugbar::error('Error!'); |
99 | | -Debugbar::warning('Watch out…'); |
100 | | -Debugbar::addMessage('Another message', 'mylabel'); |
101 | | -``` |
102 | | - |
103 | | -And start/stop timing: |
104 | | - |
105 | | -```php |
106 | | -Debugbar::startMeasure('render','Time for rendering'); |
107 | | -Debugbar::stopMeasure('render'); |
108 | | -Debugbar::addMeasure('now', LARAVEL_START, microtime(true)); |
109 | | -Debugbar::measure('My long operation', function() { |
110 | | - // Do something… |
111 | | -}); |
112 | | -``` |
113 | | - |
114 | | -Or log exceptions: |
115 | | - |
116 | | -```php |
117 | | -try { |
118 | | - throw new Exception('foobar'); |
119 | | -} catch (Exception $e) { |
120 | | - Debugbar::addException($e); |
121 | | -} |
122 | | -``` |
123 | | - |
124 | | -There are also helper functions available for the most common calls: |
125 | | - |
126 | | -```php |
127 | | -// All arguments will be dumped as a debug message |
128 | | -debug($var1, $someString, $intValue, $object); |
129 | | - |
130 | | -start_measure('render','Time for rendering'); |
131 | | -stop_measure('render'); |
132 | | -add_measure('now', LARAVEL_START, microtime(true)); |
133 | | -measure('My long operation', function() { |
134 | | - // Do something… |
135 | | -}); |
136 | | -``` |
137 | | - |
138 | | -If you want you can add your own DataCollectors, through the Container or the Facade: |
139 | | - |
140 | | -```php |
141 | | -Debugbar::addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages')); |
142 | | -//Or via the App container: |
143 | | -$debugbar = App::make('debugbar'); |
144 | | -$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages')); |
145 | | -``` |
146 | | - |
147 | | -By default, the Debugbar is injected just before `</body>`. If you want to inject the Debugbar yourself, |
148 | | -set the config option 'inject' to false and use the renderer yourself and follow http://phpdebugbar.com/docs/rendering.html |
149 | | - |
150 | | -```php |
151 | | -$renderer = Debugbar::getJavascriptRenderer(); |
152 | | -``` |
153 | | - |
154 | | -Note: Not using the auto-inject, will disable the Request information, because that is added After the response. |
155 | | -You can add the default_request datacollector in the config as alternative. |
156 | | - |
157 | | -## Enabling/Disabling on run time |
158 | | -You can enable or disable the debugbar during run time. |
159 | | - |
160 | | -```php |
161 | | -\Debugbar::enable(); |
162 | | -\Debugbar::disable(); |
163 | | -``` |
164 | | - |
165 | | -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. |
166 | | - |
167 | | - |
168 | | -## Twig Integration |
169 | | - |
170 | | -Laravel Debugbar comes with two Twig Extensions. These are tested with [rcrowe/TwigBridge](https://github.com/rcrowe/TwigBridge) 0.6.x |
171 | | - |
172 | | -Add the following extensions to your TwigBridge config/extensions.php (or register the extensions manually) |
173 | | - |
174 | | -```php |
175 | | -'Barryvdh\Debugbar\Twig\Extension\Debug', |
176 | | -'Barryvdh\Debugbar\Twig\Extension\Dump', |
177 | | -'Barryvdh\Debugbar\Twig\Extension\Stopwatch', |
178 | | -``` |
179 | | - |
180 | | -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, |
181 | | -instead of showing it directly in the template. It dumps the arguments, or when empty; all context variables. |
182 | | - |
183 | | -``` |
184 | | -{{ debug() }} |
185 | | -{{ debug(user, categories) }} |
186 | | -``` |
187 | | - |
188 | | -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. |
189 | 12 |
|
190 | 13 | ``` |
191 | | -{% stopwatch "foo" %} |
192 | | - …some things that gets timed |
193 | | -{% endstopwatch %} |
| 14 | +Asvae\ApiTester\ServiceProvider::class, |
194 | 15 | ``` |
0 commit comments