在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):barryvdh/laravel-debugbar开源软件地址(OpenSource Url):https://github.com/barryvdh/laravel-debugbar开源编程语言(OpenSource Language):PHP 76.1%开源软件介绍(OpenSource Introduction):Laravel DebugbarThis is a package to integrate PHP Debug Bar with Laravel. It includes a ServiceProvider to register the debugbar and attach it to the output. You can publish assets and configure it through Laravel. It bootstraps some Collectors to work with Laravel and implements a couple custom DataCollectors, specific for Laravel. It is configured to display Redirects and (jQuery) Ajax Requests. (Shown in a dropdown) Read the documentation for more configuration options. 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. This package includes some custom collectors:
Bootstraps the following collectors for Laravel:
And the default collectors:
It also provides a facade interface ( InstallationRequire this package with composer. It is recommended to only require the package for development. composer require barryvdh/laravel-debugbar --dev Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. The Debugbar will be enabled when
Laravel without auto-discovery:If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php Barryvdh\Debugbar\ServiceProvider::class, If you want to use the facade to log messages, add this to your facades in app.php: 'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class, The profiler is enabled by default, if you have APP_DEBUG=true. You can override that in the config ( Copy the package config to your local config with the publish command:php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider" Laravel with Octane:Make sure to add LaravelDebugbar to your flush list in 'flush' => [
\Barryvdh\Debugbar\LaravelDebugbar::class,
], Lumen:For Lumen, register a different Provider in if (env('APP_DEBUG')) {
$app->register(Barryvdh\Debugbar\LumenServiceProvider::class);
} To change the configuration, copy the file to your config folder and enable it: $app->configure('debugbar'); UsageYou can now add messages using the Facade (when added), using the PSR-3 levels (debug, info, notice, warning, error, critical, alert, emergency): Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel'); And start/stop timing: Debugbar::startMeasure('render','Time for rendering');
Debugbar::stopMeasure('render');
Debugbar::addMeasure('now', LARAVEL_START, microtime(true));
Debugbar::measure('My long operation', function() {
// Do something…
}); Or log exceptions: try {
throw new Exception('foobar');
} catch (Exception $e) {
Debugbar::addThrowable($e);
} There are also helper functions available for the most common calls: // All arguments will be dumped as a debug message
debug($var1, $someString, $intValue, $object);
// `$collection->debug()` will return the collection and dump it as a debug message. Like `$collection->dump()`
collect([$var1, $someString])->debug();
start_measure('render','Time for rendering');
stop_measure('render');
add_measure('now', LARAVEL_START, microtime(true));
measure('My long operation', function() {
// Do something…
}); If you want you can add your own DataCollectors, through the Container or the Facade: Debugbar::addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages'));
//Or via the App container:
$debugbar = App::make('debugbar');
$debugbar->addCollector(new DebugBar\DataCollector\MessagesCollector('my_messages')); By default, the Debugbar is injected just before $renderer = Debugbar::getJavascriptRenderer(); Note: Not using the auto-inject, will disable the Request information, because that is added After the response. You can add the default_request datacollector in the config as alternative. Enabling/Disabling on run timeYou can enable or disable the debugbar during run time. \Debugbar::enable();
\Debugbar::disable(); 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. Twig IntegrationLaravel Debugbar comes with two Twig Extensions. These are tested with rcrowe/TwigBridge 0.6.x Add the following extensions to your TwigBridge config/extensions.php (or register the extensions manually) 'Barryvdh\Debugbar\Twig\Extension\Debug',
'Barryvdh\Debugbar\Twig\Extension\Dump',
'Barryvdh\Debugbar\Twig\Extension\Stopwatch', The Dump extension will replace the dump function to output variables using the DataFormatter. The Debug extension adds a {{ debug() }}
{{ debug(user, categories) }} The Stopwatch extension adds a stopwatch tag similar to the one in Symfony/Silex Twigbridge. {% stopwatch "foo" %}
…some things that gets timed
{% endstopwatch %} |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论