Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase var_display_max_depth for xdebug

Tags:

php

xdebug

I recently installed xdebug on my ststem and wanted to increase xdebug.var_display_max_depth from 3 to 10. How can I go about doing that?

like image 728
Chirag Avatar asked Oct 10 '11 23:10

Chirag


People also ask

What is Xdebug Client_host?

client_host = localhost # Configures the IP address or hostname where Xdebug will attempt to connect to when initiating a debugging connection. This address should be the address of the machine where your IDE or debugging client is listening for incoming debugging connections.

How do I get rid of Xdebug 3?

As of Xdebug 3, it is possible to disable the Xdebug completely by setting the option xdebug. mode to off , or by setting the environment variable XDEBUG_MODE=off . It is very easy to disable Xdebug just for composer, by aliasing composer . You can add the alias to your $HOME/.


2 Answers

There are two ways to do that. You can edit this value locally and globally too.

  1. Local setting ("Local value") in your own PHP file:

    <?php  
        ini_set('xdebug.var_display_max_depth', '10');    
        // here comes your code...  
    ?>
    
  2. Global setting ("Master value") in php.ini:

    1. First locate your php.ini file.
      • In phpinfo(), you can get to know where it is from "Loaded Configuration File" directive.
      • You can also locate it using command prompt/terminal:
        • Windows: php --ini | findstr /C:"Loaded Configuration File"
        • Linux/UNIX-like: php --ini | grep 'Loaded Configuration File'
      • using php_ini_loaded_file(): <?php echo php_ini_loaded_file(); ?>
  3. Open your php.ini in a text editor file.
  4. You have to put something like the following to this file (in this example, I'm using php_xdebug-2.2.3-5.3-vc9-nts.dll (use http://xdebug.org/wizard.php to get to know which version you need)), and of course, you need to substitute <path to your XDebug> to the appropriate path:

    [Xdebug]  
    ;; <path to your XDebug> is like
    ;; C:\Program Files (x86)\PHP\v5.3\ext in Windows
    ;; (should be e.g. in PHP directory's "ext" subdir)
    ;; [backslash UNDER WINDOWS, / under UNIX-like operating systems]  
    zend_extension = "<path to your XDebug>\php_xdebug-2.2.3-5.3-vc9-nts.dll"  
    
    ;; HERE comes the answer to your question, we set the mentioned variable to 10  
    xdebug.var_display_max_depth = 10
    

Simple as that... you can check the results in phpinfo's xdebug part in a table: there will be a "Local value" and a "Master value" column.

Here's a sample screenshot from my localhost server; in this example, the global configuration is 3, but I set the local value to 10, with the above mentioned ini_set():

Xdebug - var_display_max_depth (Local value/Master value)

like image 149
Sk8erPeter Avatar answered Oct 19 '22 16:10

Sk8erPeter


In addition to Sk8erPeter answer you can of course set it in your .htaccess file for faster management:

php_value xdebug.var_display_max_depth 10
like image 43
silzenna Avatar answered Oct 19 '22 18:10

silzenna