9

I'm not sure why, but xdebug does not highlight var_dump(). But config seems to be fine. Have no idea why... Any suggestions?

This is my phpinfo(); http://pastebin.com/A45dqnWN

plus even xdebug_var_dump() doesn't highlight anything. It works, but look like normal var_dump().

dlitsman
  • 271
  • 2
  • 9

5 Answers5

22

I found that option "xdebug.default_enable Off Off" in you php_info(). I also have noticed that in last versions of EasyPHP this option is turned off. So turn it on by setting this line in php.ini:

xdebug.default_enable=1

Next is just common operation which disables var_dump and other errors in HTML output completely (not your case, but maybe helpful for others):

html_errors = On
happy_marmoset
  • 2,137
  • 3
  • 20
  • 25
  • 4
    Thanks, just found out that html_errors bugged for so long cause they were disabled by default in my php.ini. Big tahnks to you, upvote – Mathieu Dumoulin Jan 09 '13 at 18:39
  • Also ensure `xdebug.overload_var_dump` is 1 or 2. If set to 0 it will not replace the default php `var_dump` – Will B. Apr 30 '16 at 22:42
14

For Xdebug 3 you need to enable develop mode in your php.ini:

xdebug.mode= develop

You can also use multiple modes at once as explained here.

The following values are accepted (for xdebug.mode):

  • off

    Nothing is enabled. Xdebug does no work besides checking whether functionality is enabled. Use this setting if you want close to 0 overhead.

  • develop

    Enables Development Helpers including the overloaded var_dump().

  • coverage

    Enables Code Coverage Analysis to generate code coverage reports, mainly in combination with PHPUnit.

  • debug

    Enables Step Debugging. This can be used to step through your code while it is running, and analyse values of variables.

  • gcstats

    Enables Garbage Collection Statistics to collect statistics about PHP's Garbage Collection Mechanism.

  • profile

    Enables Profiling, with which you can analyse performance bottlenecks with tools like KCacheGrind.

  • trace

    Enables the Function Trace feature, which allows you record every function call, including arguments, variable assignment, and return value that is made during a request to a file.

You can enable multiple modes at the same time by comma separating their identifiers as value to xdebug.mode: xdebug.mode=develop,trace.

Ejaz
  • 8,719
  • 3
  • 34
  • 49
tertek
  • 890
  • 1
  • 10
  • 20
  • 3
    This worked, but it wasn't stopping at the breakpoints. But you can combine multiple modes, so make sure to have at least `xdebug.mode=develop,debug` – Shadoweb Mar 05 '21 at 16:01
  • 1
    Nice, thanks. This helped in getting pretty `var_dump` and breakpoint debugging. – Ejaz Sep 16 '22 at 10:05
7

As mentioned by @Shadoweb for Xdebug v3 you want debug to allow stopping at breakpoints, and develop to format the var_dump

The following you'll likely want in php.ini therefore:

xdebug.mode=develop,debug

As an aside, I also needed xdebug.start_with_request=yes to replace the renamed xdebug.xdebug.remote_enable=1 setting to get step debugging working in my IDE.

Jonathan Clark
  • 1,180
  • 1
  • 8
  • 26
1

For php 7.0.2 and xdebug 2.4.0

xdebug.default_enable=1

+

html_errors = On

Still does not colorize xdebug_var_dump() output.

but this patch fixes my issue. It applies to the xdebug.c and xdebug_var_dump() only. I think they made a mistake that xdebug_var_dump works only if it need to be overload function.

@@ -2191,11 +2191,6 @@
    int     i, len;
    char   *val;

-   if (!XG(overload_var_dump)) {
-       XG(orig_var_dump_func)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-       return;
-   }
-
    argc = ZEND_NUM_ARGS();

 #if PHP_VERSION_ID >= 70000
Thomas Anderson
  • 511
  • 1
  • 5
  • 14
0

Turn off xdebug.mode=debug in php.ini like

;xdebug.mode=debug

and restart Apache.

cdevries
  • 71
  • 1
  • 2