Laravel首页投稿(暂停使用,暂停投稿)

laravel 5 debugbar

2017-09-30  本文已影响0人  zigo

介绍

安装

composer require barryvdh/laravel-debugbar

使用

使用Facade方式添加调试信息,
Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel');
Debugbar::startMeasure('render','Time for rendering');
Debugbar::stopMeasure('render');
Debugbar::addMeasure('now', LARAVEL_START, microtime(true));
Debugbar::measure('My long operation', function() {
    // Do something…
});
try {
    throw new Exception('foobar');
} catch (Exception $e) {
    Debugbar::addThrowable($e);
}
使用helper function
// 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…
});
添加自己的数据收集器,通过Container或者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'));
在运行中启动或者禁止debugbar
\Debugbar::enable();
\Debugbar::disable();

debugbar开启会产生额外的开销,所以可以在配置中禁止debugbar,然后在需要debugbar的时候,在程序中使用上面对的方法开启debugbar。

上一篇 下一篇

猜你喜欢

热点阅读