首页 > 代码库 > laravel调试工具anbu使用
laravel调试工具anbu使用
参考phphub: Laravel 又一个调试利器 anbu, 里边安装少一步没写,参考github:https://github.com/daylerees/anbu
安装:
在 composer.json
的 require
字段里增加 "daylerees/anbu": "dev-master"
"require": { "laravel/framework": "4.2.*", "daylerees/anbu": "dev-master"}
执行 composer update
然后在config/app.php中增加 对应的 ServiceProvider
‘providers‘ => array( ... ‘Illuminate\View\ViewServiceProvider‘, ‘Illuminate\Workbench\WorkbenchServiceProvider‘, ‘Anbu\ProfilerServiceProvider‘,),
alias 数组中加入 Anbu Facade
‘aliases‘ => array( ... ‘Anbu‘ => ‘Anbu\Facades\Anbu‘)
发布探查资源文件( publish profiler asset files ): php artisan asset:publish
同时, 要配置好对应的 database 连接 因为 anbu 会引入一张表用于存储相关的信息。
使用:
为了更好的看到相关功能, 在 route.php
文件中, 我们加入以下测试代码:
//route.phpRoute::get(‘/‘, function(){ //Debug, When you use dd()
you risk exposing information to the users of your application. Instead, use ad()
to dump this data into the ‘Debug‘ section of Anbu. ad(‘foo‘); ad(‘3‘); ad(‘30.33‘); ad(with(new stdClass)->foo = ‘bar‘); ad([‘name‘ => ‘zhangsan‘, ‘age‘ => 14]); //timers, 在app.php中添加的Facade就是为这个准备的,其他地方没用到Anbu类。 Anbu::timers()->start(‘test‘); sleep(1); // Do something interesting. Anbu::timers()->end(‘test‘, ‘Completed doing something.‘); //db query \DB::table(‘anbu‘)->get(); //log entries \Log::info(‘info message‘); \Log::info(‘another message‘); \Log::error(‘wrong message‘); return View::make(‘hello‘);});Route::post(‘/foo/baz/boo‘, ‘Anbu\\Controller\AssetController@index‘);Route::patch(‘/foo/bar‘, ‘Anbu\\Controller\AssetController@index‘);Route::put(‘/foo/bar‘, ‘Anbu\\Controller\AssetController@index‘);Route::delete(‘/foo‘, ‘Anbu\\Controller\AssetController@index‘);
隐藏和禁用:
First let me explain the two concepts.
To hide is to eliminate the Laravel icon button from requests, so that it won‘t interfere with certain content types.
To disable is to stop the profiler from storing the request, and displaying the button. Data for this request will be lost.
You can hide the profiler using:
Anbu::hide();
Or you can apply the anbu.hide
filter as a before
filter to any route or route group.
You can disable the profiler using:
Anbu::disable();
Or you can apply the anbu.disable
filter as a before
filter to any route or route group.
问题解决:
If a new module is added, then you might get an error when rendering a previous request.
Here‘s some things you can try if you have any problems. First you can try updating Anbu with:
composer update
Secondly you can clear the previous requests with the following Artisan command.
php artisan anbu:clear
laravel调试工具anbu使用