Disable HTML stack traces by Xdebug

23,120

Solution 1

Check for xdebug_disable()Docs:

Disables stack traces

Disable showing stack traces on error conditions.

See as well xdebug.default_enableDocs.

Solution 2

You need to make sure you have html_errors=0 in PHP as well. Also, orange isn't horrible ;-)

Solution 3

Add following code in the initialization Script:

 if (function_exists('xdebug_disable')) {
           xdebug_disable();
         }
Share:
23,120
Álvaro González
Author by

Álvaro González

Hi! I'm not asking you to enable error reporting, share the verbatim error message, inspect variables... to annoy you and show off how much fancy stuff I know. That's the straightforward problem solving method. Why guess and try random stuff for days when the language engine can tell you the exact issue? If you don't know what I mean or how to apply it, please don't pretend you didn't read my comments. Instead, ask for clarifications—I'll be glad to guide you. Further listening Mi sitio de programación en español: Borrame.com The humour site I haven't updated since 2004: Demogracia Mi hosting actual: Guebs.com

Updated on July 09, 2022

Comments

  • Álvaro González
    Álvaro González almost 2 years

    The administrator has installed Xdebug 2.1.1 in our shared PHP 5.3.0 server in order to use its debugger. Now, I can hardly read the stack traces of uncatched exceptions because they are formatted by Xdebug with annoying colours that interact badly with the site's CSS:

    Unreadable stack trace

    Since PHP runs as Apache module, I've tried to disable this feature in an .htaccess file but I can't make it go:

    php_flag xdebug.default_enable Off
    php_flag xdebug.overload_var_dump Off
    php_flag xdebug.show_exception_trace Off
    php_value xdebug.trace_format 1
    

    phpinfo() shows my changes in the Local Value column but I can still see those horrible orange tables. What's the directive I need to change?

  • Álvaro González
    Álvaro González almost 13 years
    I'm not sure I get it. I already use HTML errors, together with error_prepend_string and error_append_string so I can display line feeds. If I disable it, Xdebug does not draw HTML but that makes the error unreadable as well because everything's in a single line. I don't want to search for error messages in the View Source window...
  • Álvaro González
    Álvaro González almost 13 years
    xdebug.default_enable has no apparent effect, but calling xdebug_disable() on top of my code works fine. I'll see how to pack it in my web site settings.
  • hakre
    hakre almost 13 years
    Try to put xdebug.default_enable into the system's php.ini, maybe that works. Additionally probably using 0 instead of off in the .htaccess configuration might also help, but that's just an assumption, I have not tested it.
  • Álvaro González
    Álvaro González almost 13 years
    Alright... I've done further testing and the directive is xdebug.default_enable but it seems there's a bug somewhere: in the shared development server it's ignored, in my local installation its fully honoured.
  • hakre
    hakre almost 13 years
    @Álvaro G. Vicario: Are you still using the .htaccess configuration method or are you using php.ini? Just asking for clarification.
  • Álvaro González
    Álvaro González almost 13 years
    Just tried .htaccess (being a shared resouce, I don't want to disturb others). It's worth nothing that phpinfo() reports the directive as changed in all cases. I wrote a quick workaround with auto_prepend_file that works for me.
  • hakre
    hakre almost 13 years
    I was close to suggest auto prepend file as well, however I really wonder why the .htaccess rules do not properly work. Maybe it's a mod_php issue or something.
  • Dr Casper Black
    Dr Casper Black about 11 years
    xdebug.default_enable=off in php.ini worked with php5.4 on debian
  • Álvaro González
    Álvaro González over 9 years
    Please note that remote_autostart and remote_enable control the debugger. They have nothing to do with stack traces.
  • Pere
    Pere over 8 years
    Very useful if you are outputting json from PHP for use with Javascript, angular, and that all.
  • rockerston
    rockerston about 8 years
    Like Alvaro said, Option #2 here has nothing to do with displaying the HTML stack trace.
  • Sumoanand
    Sumoanand about 8 years
    Updated as per suggestion.
  • Jeroen Vermeulen - MageHost
    Jeroen Vermeulen - MageHost about 7 years
    If @derick answers you had better listen. He wrote XDebug.