20

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
  • 142,137
  • 41
  • 261
  • 360

3 Answers3

14

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

Derick
  • 35,169
  • 5
  • 76
  • 99
  • 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 Aug 02 '11 at 12:29
  • Very useful if you are outputting json from PHP for use with Javascript, angular, and that all. – Pere Jan 07 '16 at 16:45
  • 6
    If @derick answers you had better listen. He wrote XDebug. – Jeroen Vermeulen - MageHost May 29 '17 at 09:30
14

Check for xdebug_disable()Docs:

Disables stack traces

Disable showing stack traces on error conditions.

See as well xdebug.default_enableDocs.

hakre
  • 193,403
  • 52
  • 435
  • 836
  • `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. – Álvaro González Aug 02 '11 at 12:43
  • 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. – hakre Aug 03 '11 at 19:23
  • 1
    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. – Álvaro González Aug 04 '11 at 08:58
  • @Álvaro G. Vicario: Are you still using the .htaccess configuration method or are you using php.ini? Just asking for clarification. – hakre Aug 04 '11 at 09:00
  • 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. – Álvaro González Aug 04 '11 at 09:09
  • 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. – hakre Aug 04 '11 at 09:12
  • xdebug.default_enable=off in php.ini worked with php5.4 on debian – Dr Casper Black May 03 '13 at 11:05
6

Add following code in the initialization Script:

 if (function_exists('xdebug_disable')) {
           xdebug_disable();
         }
Sumoanand
  • 8,835
  • 2
  • 47
  • 46