Disable HTML stack traces by Xdebug
Asked Answered
H

3

21

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?

Hobnob answered 2/8, 2011 at 12:13 Comment(1)
xdebug.org/docs/stack_traceSnocat
S
14

Check for xdebug_disable()Docs:

Disables stack traces

Disable showing stack traces on error conditions.

See as well xdebug.default_enableDocs:

boolean xdebug.default_enable = true

If this setting is 1, then stacktraces will be shown by default on an error event. You can disable showing stacktraces from your code with xdebug_disable(). As this is one of the basic functions of Xdebug, it is advisable to leave this setting set to 1.

Snocat answered 2/8, 2011 at 12:27 Comment(7)
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.Olomouc
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.Snocat
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.Olomouc
@Álvaro G. Vicario: Are you still using the .htaccess configuration method or are you using php.ini? Just asking for clarification.Snocat
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.Olomouc
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.Snocat
xdebug.default_enable=off in php.ini worked with php5.4 on debianGripper
Z
14

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

Zoril answered 2/8, 2011 at 12:21 Comment(3)
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...Olomouc
Very useful if you are outputting json from PHP for use with Javascript, angular, and that all.Plank
If @derick answers you had better listen. He wrote XDebug.Grimbal
S
14

Check for xdebug_disable()Docs:

Disables stack traces

Disable showing stack traces on error conditions.

See as well xdebug.default_enableDocs:

boolean xdebug.default_enable = true

If this setting is 1, then stacktraces will be shown by default on an error event. You can disable showing stacktraces from your code with xdebug_disable(). As this is one of the basic functions of Xdebug, it is advisable to leave this setting set to 1.

Snocat answered 2/8, 2011 at 12:27 Comment(7)
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.Olomouc
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.Snocat
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.Olomouc
@Álvaro G. Vicario: Are you still using the .htaccess configuration method or are you using php.ini? Just asking for clarification.Snocat
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.Olomouc
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.Snocat
xdebug.default_enable=off in php.ini worked with php5.4 on debianGripper
A
6

Add following code in the initialization Script:

 if (function_exists('xdebug_disable')) {
           xdebug_disable();
         }
Aeolic answered 6/2, 2014 at 19:15 Comment(2)
Like Alvaro said, Option #2 here has nothing to do with displaying the HTML stack trace.Syndetic
Updated as per suggestion.Aeolic

© 2022 - 2024 — McMap. All rights reserved.