php laravel 开发工具,Laravel Debugbar:Laravel 调试工具条(集成PHP Debug Bar)

Laravel Debugbar

625332134c6f4d4600884b99daebf603.png625332134c6f4d4600884b99daebf603.png625332134c6f4d4600884b99daebf603.png

Note for v3: Debugbar is now enabled by requiring the package, but still needs APP_DEBUG=true by default!

For Laravel < 5.5, please use the 2.4 branch!

This is a package to integrate PHP Debug Bar with Laravel 5. 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.

625332134c6f4d4600884b99daebf603.png

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:

QueryCollector: Show all queries, including binding + timing

RouteCollector: Show information about the current Route.

ViewCollector: Show the currently loaded views. (Optionally: display the shared data)

EventsCollector: Show all events

LaravelCollector: Show the Laravel version and Environment. (disabled by default)

SymfonyRequestCollector: replaces the RequestCollector with more information about the request/response

LogsCollector: Show the latest log entries from the storage logs. (disabled by default)

FilesCollector: Show the files that are included/required by PHP. (disabled by default)

ConfigCollector: Display the values from the config files. (disabled by default)

CacheCollector: Display all cache events. (disabled by default)

Bootstraps the following collectors for Laravel:

LogCollector: Show all Log messages

SwiftMailCollector and SwiftLogCollector for Mail

And the default collectors:

PhpInfoCollector

MessagesCollector

TimeDataCollector (With Booting and Application timing)

MemoryCollector

ExceptionsCollector

It also provides a Facade interface for easy logging Messages, Exceptions and Time

Installation

Require this package with composer. It is recommended to only require the package for development.

composer require barryvdh/laravel-debugbar --dev

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

The Debugbar will be enabled when APP_DEBUG is true.

If you use a catch-all/fallback route, make sure you load the Debugbar ServiceProvider before your own App ServiceProviders.

Laravel 5.5+:

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\Facade::class,

The profiler is enabled by default, if you have APP_DEBUG=true. You can override that in the config (debugbar.enabled) or by setting DEBUGBAR_ENABLED in your .env. See more options in config/debugbar.php 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. You can also only display the js or css vendors, by setting it to 'js' or 'css'. (Highlight.js requires both css + js, so set to true for syntax highlighting)

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"

Lumen:

For Lumen, register a different Provider in bootstrap/app.php:

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');

Usage

You 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);

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值