Hi,
I'd like to disable the debugbar on some routes. I am developing a REST API and each time, the API attaches the debugbar :) I'd like to disable this for some routes.
Is this possible?
Thanks in advance.
What are you returning from your API? It shouldn't affect json/xml responses at all, only text/html responses.
You can set a filter and just call that on your routes.
Route::filter('nodebugbar', function()
{
\Debugbar::disable();
});
Route::when('api/*', 'nodebugbar');
Do you still have this problem?
How do you do this in laravel 5 ?
Currently I'm doing
Route::post('api', function (IlluminateHttpRequest $request) {
Debugbar::disable();
if(!$request->has('grant_type')) {
$request->merge([
'grant_type' => 'password'
]);
}
return Response::json(Authorizer::issueAccessToken());
});
look at #409
I called this within my control, and it worked for me:
app('debugbar')->disable();
I just use a handly middleware in my route group.
https://gist.github.com/besrabasant/dd46023f2e09a9000db6db26099e0ae1
Then Register your Middleware in your AppServiceProvider class.
public function boot()
{
//
$this->app['router']->aliasMiddleware('noDebugbar', App\Http\Middleware\NoDebugbar::class);
}
Then, in your web.php
Route::group(['middlware' => 'noDebugbar'], function() {
Route::get('/', function() {
return view('view');
});
});
Most helpful comment
I called this within my control, and it worked for me:
app('debugbar')->disable();