Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yousan's avatar

What is a best practice to disable debug output when accessing by commandline?

Hi.

Laravel debug info is really useful and helps me.

When I developing an API or something server-side functions, sometimes I don't need those debug messages.

How should I disable those debug modes?

  1. Add a disable stuffs at a route.
Roeute::get( '/delivery_statement', function() {
    \Debugbar::disable();   // this doesn't woks at here
        some_undefined_function_called_it_causes_an_error();
});
  1. Add an HTTP header such as 'Laravel-Disable-Debug: disabled', and detect it on serverside.
curl -H 'Laravel-Disable-Debug: disabled' http://localhost/api/path-to/debug

Any ideas?

Thanks!

0 likes
3 replies
Sergiu17's avatar

Usually on production you never need those debug messages.

Open .env file

APP_DEBUG=false

and clear cache

1 like
yousan's avatar

@sergiu17 Thank you for your reply ;)

I just disable debug from commandline access. To rewrite .env file, I have to open .env, edit and save.

I just want to disable (or... something useful mode for commandline) debugging at commandline.

Sergiu17's avatar

@YOUSAN - ok, got it. you could make use of app()->runningInConsole(). Add this is AppServiceProvider, should work

if(app()->runningInConsole()) {
    \Debugbar::disable();
}

Please or to participate in this conversation.