![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
XDEBUG EXTENSION FOR PHP | DOCUMENTATIONInstallationThis section describes on how to install Xdebug. Precompiled Windows ModulesThere are a few precompiled modules for Windows, they are all for the non-debug version of PHP. You can get those at the download page. Follow these instructions to get Xdebug installed. PECL InstallationAs of Xdebug 0.9.0 you can install Xdebug through PEAR/PECL. This only works with with PEAR version 0.9.1-dev or higher and some UNIX. Installing with PEAR/PECL is as easy as: # pecl install xdebug but you still need to add the correct line to your php.ini: (don't forget to change the path and filename to the correct one — but make sure you use the full path) zend_extension="/usr/local/php/modules/xdebug.so" Note: You should ignore any prompts to add "extension=xdebug.so" to php.ini — this will cause problems. Installation on Mac OS X via HomebrewPHP and Xdebug are available from the unofficial Mac OS X package manager Homebrew. If you use PHP installed via Homebrew (see this installation guide for details on how to do that) Xdebug can be installed via brew install: # brew install <php-version>-xdebug eg. # brew install php56-xdebug You can also use brew search to locate the specific package you need: # brew search xdebug The Xdebug extension will be enabled per default after the installation, additional configuration of the extension should be done by adding a custom ini-file to /usr/local/etc/php/<php-version>/conf.d/ . See the Caveats output at the end of the installation for more details. Installation From SourceYou can download the source of the latest stable release 2.2.5. Alternatively you can obtain Xdebug from GIT: git clone git://github.com/xdebug/xdebug.git This will checkout the latest development version which is currently 2.2.5. You can also browse the source at https://github.com/derickr/xdebug. CompilingThere is a wizard available that provides you with the correct file to download, and which paths to use.
You compile Xdebug separately from the rest of PHP. Note, however,
that you need access to the scripts 'phpize' and 'php-config'. If
your system does not have 'phpize' and 'php-config', you will need to
compile and install PHP from a source tarball first, as these script
are by-products of the PHP compilation and installation processes. (Debian users
can install the required tools with
Configure PHP to Use Xdebug
CompatibilityXdebug does not work together with the Zend Optimizer or any other extension that deals with PHP's internals (DBG, APD, ioncube etc). This is due to compatibility problems with those modules. Debugclient InstallationUnpack the Xdebug source tarball and issue the following commands: $ cd debugclient $ ./configure --with-libedit $ make # make install
This will install the debugclient binary in /usr/local/bin unless you don't
have libedit installed on your system. You can either install it, or leave
out the '--with-libedit' option to configure. Debian 'unstable' users can
install the library with If the configure script can not find libedit and you are sure you have (and it's headers) installed correctly and you get link errors like the following in your configure.log: /usr/lib64/libedit.so: undefined reference to `tgetnum' /usr/lib64/libedit.so: undefined reference to `tgoto' /usr/lib64/libedit.so: undefined reference to `tgetflag' /usr/lib64/libedit.so: undefined reference to `tputs' /usr/lib64/libedit.so: undefined reference to `tgetent' /usr/lib64/libedit.so: undefined reference to `tgetstr' collect2: ld returned 1 exit status you need to change your configure command to: $ LDFLAGS=-lncurses ./configure --with-libedit Variable Display FeaturesXdebug replaces PHP's var_dump() function for displaying variables. Xdebug's version includes different colors for different types and places limits on the amount of array elements/object properties, maximum depth and string lengths. There are a few other functions dealing with variable display as well. Effect of settings on var_dump()There is a number of settings that control the output of Xdebug's modified var_dump() function: xdebug.var_display_max_children, xdebug.var_display_max_data and xdebug.var_display_max_depth. The effect of these three settings is best shown with an example. The script below is run four time, each time with different settings. You can use the tabs to see the difference. The script
The resultsarray 'one' => string 'a somewhat long string!' (length=23) 'two' => array 'two.one' => array 'two.one.zero' => int 210 'two.one.one' => array ... 'three' => object(test)[1] public 'pub' => &object(test)[1] private 'priv' => boolean true protected 'prot' => int 42 'four' => array 0 => int 0 1 => int 1 2 => int 2 3 => int 3 4 => int 4 5 => int 5 array 'one' => string 'a somewhat long string!' (length=23) 'two' => array 'two.one' => array 'two.one.zero' => int 210 'two.one.one' => array ... more elements... array 'one' => string 'a somewhat long '... (length=23) 'two' => array 'two.one' => array 'two.one.zero' => int 210 'two.one.one' => array ... 'three' => object(test)[1] public 'pub' => &object(test)[1] private 'priv' => boolean true protected 'prot' => int 42 'four' => array 0 => int 0 1 => int 1 2 => int 2 3 => int 3 4 => int 4 5 => int 5 array 'one' => string 'a somewhat long string!' (length=23) 'two' => array 'two.one' => array ... 'three' => object(test)[1] public 'pub' => &object(test)[1] private 'priv' => boolean true protected 'prot' => int 42 'four' => array 0 => int 0 1 => int 1 2 => int 2 3 => int 3 4 => int 4 5 => int 5 array 'one' => string 'a somewh'... (length=23) 'two' => array ... 'three' => object(test)[1] ... more elements... Related Settingsxdebug.cli_color
Type: integer, Default value: 0, Introduced in Xdebug >= 2.2
If this setting is 1, Xdebug will color var_dumps and stack traces output when in CLI mode and when the output is a tty. On Windows, the ANSICON tool needs to be installed. If the setting is 2, then Xdebug will always color var_dumps and stack trace, no matter whether it's connected to a tty or whether ANSICON is installed. In this case, you might end up seeing escape codes. See this article for some more information. xdebug.overload_var_dump
Type: boolean, Default value: 2, Introduced in Xdebug > 2.1
By default Xdebug overloads var_dump() with its own improved version
for displaying variables when the html_errors php.ini setting is set to
You can also use Before Xdebug 2.4, the default value of this setting was
xdebug.var_display_max_children
Type: integer, Default value: 128
Controls the amount of array children and object's properties are shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_data
Type: integer, Default value: 512
Controls the maximum string length that is shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_depth
Type: integer, Default value: 3
Controls how many nested levels of array elements and object properties are when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. The maximum value you can select is 1023. You can also use -1 as value to select this maximum number. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. Related Functionsvoid var_dump( [mixed var [, ...]] )
Displays detailed information about a variable
This function is overloaded by Xdebug, see the description for xdebug_var_dump(). void xdebug_debug_zval( [string varname [, ...]] )
Displays information about a variable
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. This function is implemented differently from PHP's debug_zval_dump() function in order to work around the problems that that function has because the variable itself is actually passed to the function. Xdebug's version is better as it uses the variable name to lookup the variable in the internal symbol table and accesses all the properties directly without having to deal with actually passing a variable to a function. The result is that the information that this function returns is much more accurate than PHP's own function for showing zval information. Support for anything but simple variable names (such as "a[2]" below) is supported since Xdebug 2.3. Example:
<?php Returns:
a: (refcount=2, is_ref=1)=array ( 0 => (refcount=1, is_ref=0)=1, 1 => (refcount=1, is_ref=0)=2, 2 => (refcount=2, is_ref=1)=3) a[2]: (refcount=2, is_ref=1)=3 void xdebug_debug_zval_stdout( [string varname [, ...]] )
Returns information about variables to stdout.
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. The difference with xdebug_debug_zval() is that the information is not displayed through a web server API layer, but directly shown on stdout (so that when you run it with Apache in single process mode it ends up on the console). Example:
<?php Returns:
a: (refcount=2, is_ref=1)=array ( 0 => (refcount=1, is_ref=0)=1, 1 => (refcount=1, is_ref=0)=2, 2 => (refcount=2, is_ref=1)=3) void xdebug_dump_superglobals()
Displays information about super globals
This function dumps the values of the elements of the super globals as specified with the xdebug.dump.* php.ini settings. For the example below the settings in php.ini are: Example:
xdebug.dump.GET=* Returns:
void xdebug_var_dump( [mixed var [, ...]] )
Displays detailed information about a variable
This function displays structured information about one or more expressions that includes its type and value. Arrays are explored recursively with values. See the introduction of Variable Display Features on which php.ini settings affect this function. Example:
<?php Returns:
array 0 => array 0 => boolean true 1 => int 2 2 => float 3.14 more elements... 'object' => object(stdClass)[1] public 'foo' => string 'bar' (length=3) public 'file' => resource(3, stream) Stack TracesWhen Xdebug is activated it will show a stack trace whenever PHP decides to show a notice, warning, error etc. The information that stack traces display, and the way how they are presented, can be configured to suit your needs. The stack traces that Xdebug shows on error situations (if display_errors is set to On in php.ini) are quite conservative in the amount of information that they show. This is because large amounts of information can slow down both the execution of the scripts and the rendering of the stack traces themselves in the browser. However, it is possible to make the stack traces show more detailed information with different settings. Variables in Stack TracesBy default Xdebug will now show variable information in the stack traces that it produces. Variable information can take quite a bit of resources, both while collecting or displaying. However, in many cases it is useful that variable information is displayed, and that is why Xdebug has the setting xdebug.collect_params. The script below, in combination with what the output will look like with different values of this setting is shown in the example below. The script
The resultsDifferent values for the xdebug.collect_params setting give different output, which you can see below:
ini_set('xdebug.collect_params', '1');
ini_set('xdebug.collect_params', '2');
ini_set('xdebug.collect_params', '3');
ini_set('xdebug.collect_params', '4');
Additional InformationOn top of showing the values of variables that were passed to each function Xdebug can also optionally show information about selected superglobals by using the xdebug.dump_globals and xdebug.dump.* settings. The settings xdebug.dump_once and xdebug.dump_undefined slightly modify when and which information is shown from the available superglobals. With the xdebug.show_local_vars setting you can instruct Xdebug to show all variables available in the top-most stack level for a user defined function as well. The examples below show this (the script is used from the example above).
ini_set('xdebug.collect_vars', 'on'); ini_set('xdebug.collect_params', '4'); ini_set('xdebug.dump_globals', 'on'); ini_set('xdebug.dump.SERVER', 'REQUEST_URI');
ini_set('xdebug.collect_vars', 'on'); ini_set('xdebug.collect_params', '4'); ini_set('xdebug.dump_globals', 'on'); ini_set('xdebug.dump.SERVER', 'REQUEST_URI'); ini_set('xdebug.show_local_vars', 'on');
Related Settingsxdebug.cli_color
Type: integer, Default value: 0, Introduced in Xdebug >= 2.2
If this setting is 1, Xdebug will color var_dumps and stack traces output when in CLI mode and when the output is a tty. On Windows, the ANSICON tool needs to be installed. If the setting is 2, then Xdebug will always color var_dumps and stack trace, no matter whether it's connected to a tty or whether ANSICON is installed. In this case, you might end up seeing escape codes. See this article for some more information. xdebug.collect_includes
Type: boolean, Default value: 1
This setting, defaulting to 1, controls whether Xdebug should write the
filename used in include(), include_once(), require() or require_once() to the
trace files.
xdebug.collect_params
Type: integer, Default value: 0
This setting, defaulting to 0, controls whether Xdebug should collect the parameters passed to functions when a function call is recorded in either the function trace or the stack trace. The setting defaults to 0 because for very large scripts it may use huge amounts of memory and therefore make it impossible for the huge script to run. You can most safely turn this setting on, but you can expect some problems in scripts with a lot of function calls and/or huge data structures as parameters. Xdebug 2 will not have this problem with increased memory usage, as it will never store this information in memory. Instead it will only be written to disk. This means that you need to have a look at the disk usage though. This setting can have four different values. For each of the values a different amount of information is shown. Below you will see what information each of the values provides. See also the introduction of the feature Stack Traces for a few screenshots.
1 in the CLI version of PHP it will not have the tool tip, nor in output files. xdebug.collect_vars
Type: boolean, Default value: 0
This setting tells Xdebug to gather information about which variables
are used in a certain scope. This analysis can be quite slow as Xdebug has
to reverse engineer PHP's opcode arrays. This setting will not record which
values the different variables have, for that use xdebug.collect_params.
This setting needs to be enabled only if you wish to use
xdebug_get_declared_vars().
xdebug.dump.*
Type: string, Default value: Empty
* can be any of COOKIE, FILES, GET, POST, REQUEST, SERVER, SESSION. These seven settings control which data from the superglobals is shown when an error situation occurs. Each of those php.ini setting can consist of a comma seperated list of
variables from this superglobal to dump, or In order to dump the REMOTE_ADDR and the REQUEST_METHOD when an error occurs, and all GET parameters, add these settings: xdebug.dump.SERVER = REMOTE_ADDR,REQUEST_METHOD xdebug.dump.GET = * xdebug.dump_globals
Type: boolean, Default value: 1
Controls whether the values of the superglobals as defined by the xdebug.dump.* settings should be shown or not.
xdebug.dump_once
Type: boolean, Default value: 1
Controls whether the values of the superglobals should be dumped on all
error situations (set to 0) or only on the first (set to 1).
xdebug.dump_undefined
Type: boolean, Default value: 0
If you want to dump undefined values from the superglobals you should set
this setting to 1, otherwise leave it set to 0.
xdebug.file_link_format
Type: string, Default value: , Introduced in Xdebug >= 2.1
This setting determines the format of the links that are made in the display of stack traces where file names are used. This allows IDEs to set up a link-protocol that makes it possible to go directly to a line and file by clicking on the filenames that Xdebug shows in stack traces. An example format might look like: myide://%f@%l The possible format specifiers are:
For various IDEs/OSses there are some instructions listed on how to make this work: Firefox on Linux
Windows and netbeans
xdebug.manual_url
Type: string, Default value: http://www.php.net, Introduced in Xdebug < 2.2.1
This is the base url for the links from the function traces and error
message to the manual pages of the function from the message. It is advisable
to set this setting to use the closest mirror.
xdebug.show_error_trace
Type: integer, Default value: 0, Introduced in Xdebug >= 2.4
When this setting is set to 1, Xdebug will show a stack trace whenever
an Error is raised - even if this Error is actually caught.
xdebug.show_exception_trace
Type: integer, Default value: 0
When this setting is set to 1, Xdebug will show a stack trace whenever an Exception or Error is raised - even if this Exception or Error is actually caught. Error 'exceptions' were introduced in PHP 7. xdebug.show_local_vars
Type: integer, Default value: 0
When this setting is set to something != 0 Xdebug's generated stack dumps
in error situations will also show all variables in the top-most scope. Beware
that this might generate a lot of information, and is therefore turned off by
default.
xdebug.show_mem_delta
Type: integer, Default value: 0
When this setting is set to something != 0 Xdebug's human-readable
generated trace files will show the difference in memory usage between function
calls. If Xdebug is configured to generate computer-readable trace files then
they will always show this information.
xdebug.var_display_max_children
Type: integer, Default value: 128
Controls the amount of array children and object's properties are shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_data
Type: integer, Default value: 512
Controls the maximum string length that is shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_depth
Type: integer, Default value: 3
Controls how many nested levels of array elements and object properties are when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. The maximum value you can select is 1023. You can also use -1 as value to select this maximum number. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. Related Functionsarray xdebug_get_declared_vars()
Returns declared variables
Returns an array where each element is a variable name which is defined in the current scope. The setting xdebug.collect_vars needs to be enabled. Example:
<?php Returns:
array 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'item' (length=4) In PHP versions before 5.1, the variable name "a" is not in the returned array, as it is not used in the scope where the function xdebug_get_declared_vars() is called in. array xdebug_get_function_stack()
Returns information about the stack
Returns an array which resembles the stack trace up to this point. The example script: Example:
<?php Returns:
array 0 => array 'function' => string '{main}' (length=6) 'file' => string '/var/www/xdebug_get_function_stack.php' (length=63) 'line' => int 0 'params' => array empty 1 => array 'function' => string 'fix_strings' (length=11) 'class' => string 'strings' (length=7) 'file' => string '/var/www/xdebug_get_function_stack.php' (length=63) 'line' => int 18 'params' => array 'b' => string 'array (0 => 'Derick')' (length=21) 2 => array 'function' => string 'fix_string' (length=10) 'class' => string 'strings' (length=7) 'file' => string '/var/www/xdebug_get_function_stack.php' (length=63) 'line' => int 12 'params' => array 'a' => string ''Derick'' (length=8) array xdebug_get_monitored_functions()
Returns information about monitored functions
Introduced in version 2.4
Returns a structure which contains information about where the monitored functions were executed in your script. The following example shows how to use this, and the returned information: Example:
<?php Returns:
/tmp/monitor-example.php:10: array(2) { [0] => array(3) { 'function' => string(6) "strrev" 'filename' => string(24) "/tmp/monitor-example.php" 'lineno' => int(6) } [1] => array(3) { 'function' => string(6) "strrev" 'filename' => string(24) "/tmp/monitor-example.php" 'lineno' => int(8) } } integer xdebug_get_stack_depth()
Returns the current stack depth level
Returns the stack depth level. The main body of a script is level 0 and each include and/or function call adds one to the stack depth level. none xdebug_print_function_stack( [ string message [, int options ] ] )
Displays the current function stack.
Displays the current function stack, in a similar way as what Xdebug would display in an error situation. The "message" argument allows you to replace the message in the header with your own. (Introduced in Xdebug 2.1). Example:
<?php Returns:
The bitmask "options" allows you to configure a few extra options. The following options are currently supported:
void xdebug_start_function_monitor( array $list_of_functions_to_monitor )
Starts function monitoring
Introduced in version 2.4
This function starts the monitoring of functions that were given in a list as argument to this function. Function monitoring allows you to find out where in your code the functions that you provided as argument are called from. This can be used to track where old, or, discouraged functions are used. Example:
<?php You can also add class methods and static methods to the array that defines which functions to monitor. For example, to catch static calls to DramModel::canSee and dynamic calls to Whisky->drink, you would start the monitor with: Example:
<?php The defined functions are case sensitive, and a dynamic call to a static method will not be caught. void xdebug_stop_function_monitor()
Stops monitoring functions
Introduced in version 2.4
This function stops the function monitor. In order to get the list of monitored functions, you need to use the xdebug_get_monitored_functions() function. Function TracesXdebug allows you to log all function calls, including parameters and return values to a file in different formats. Those so-called "function traces" can be a help for when you are new to an application or when you are trying to figure out what exactly is going on when your application is running. The function traces can optionally also show the values of variables passed to the functions and methods, and also return values. In the default traces those two elements are not available. Output FormatsThere are three output formats. One is meant as a human readable trace, another one is more suited for computer programs as it is easier to parse, and the last one uses HTML for formatting the trace. You can switch between the two different formats with the xdebug.trace_format setting. There are a few settings that control which information is written to the trace files. There are settings for including variables (xdebug.collect_params) and for including return values (xdebug.collect_return) for example. The example below shows what effect the different settings have for the human readable function traces. The Script
The ResultsBelow are the results with different settings of the xdebug.collect_params setting. As this is not a web environment the value of 2 does not have any meaning as tool tips don't work in text files. TRACE START [2007-05-06 14:37:06] 0.0003 114112 -> {main}() ../trace.php:0 0.0004 114272 -> str_split() ../trace.php:8 0.0153 117424 -> ret_ord() ../trace.php:10 0.0165 117584 -> ord() ../trace.php:5 0.0166 117584 -> ret_ord() ../trace.php:10 0.0167 117584 -> ord() ../trace.php:5 0.0168 117584 -> ret_ord() ../trace.php:10 0.0168 117584 -> ord() ../trace.php:5 0.0170 117584 -> ret_ord() ../trace.php:10 0.0170 117584 -> ord() ../trace.php:5 0.0172 117584 -> ret_ord() ../trace.php:10 0.0172 117584 -> ord() ../trace.php:5 0.0173 117584 -> ret_ord() ../trace.php:10 0.0174 117584 -> ord() ../trace.php:5 0.0177 41152 TRACE END [2007-05-06 14:37:07] TRACE START [2007-05-06 14:37:11] 0.0003 114112 -> {main}() ../trace.php:0 0.0004 114272 -> str_split(string(6)) ../trace.php:8 0.0007 117424 -> ret_ord(string(1)) ../trace.php:10 0.0007 117584 -> ord(string(1)) ../trace.php:5 0.0009 117584 -> ret_ord(string(1)) ../trace.php:10 0.0009 117584 -> ord(string(1)) ../trace.php:5 0.0010 117584 -> ret_ord(string(1)) ../trace.php:10 0.0011 117584 -> ord(string(1)) ../trace.php:5 0.0012 117584 -> ret_ord(string(1)) ../trace.php:10 0.0013 117584 -> ord(string(1)) ../trace.php:5 0.0014 117584 -> ret_ord(string(1)) ../trace.php:10 0.0014 117584 -> ord(string(1)) ../trace.php:5 0.0016 117584 -> ret_ord(string(1)) ../trace.php:10 0.0016 117584 -> ord(string(1)) ../trace.php:5 0.0019 41152 TRACE END [2007-05-06 14:37:11] TRACE START [2007-05-06 14:37:13] 0.0003 114112 -> {main}() ../trace.php:0 0.0004 114272 -> str_split('Xdebug') ../trace.php:8 0.0007 117424 -> ret_ord('X') ../trace.php:10 0.0007 117584 -> ord('X') ../trace.php:5 0.0009 117584 -> ret_ord('d') ../trace.php:10 0.0009 117584 -> ord('d') ../trace.php:5 0.0010 117584 -> ret_ord('e') ../trace.php:10 0.0011 117584 -> ord('e') ../trace.php:5 0.0012 117584 -> ret_ord('b') ../trace.php:10 0.0013 117584 -> ord('b') ../trace.php:5 0.0014 117584 -> ret_ord('u') ../trace.php:10 0.0014 117584 -> ord('u') ../trace.php:5 0.0016 117584 -> ret_ord('g') ../trace.php:10 0.0016 117584 -> ord('g') ../trace.php:5 0.0019 41152 TRACE END [2007-05-06 14:37:13] TRACE START [2007-05-06 14:37:16] 0.0003 114112 -> {main}() ../trace.php:0 0.0004 114272 -> str_split('Xdebug') ../trace.php:8 0.0007 117424 -> ret_ord($c = 'X') ../trace.php:10 0.0007 117584 -> ord('X') ../trace.php:5 0.0009 117584 -> ret_ord($c = 'd') ../trace.php:10 0.0009 117584 -> ord('d') ../trace.php:5 0.0010 117584 -> ret_ord($c = 'e') ../trace.php:10 0.0011 117584 -> ord('e') ../trace.php:5 0.0012 117584 -> ret_ord($c = 'b') ../trace.php:10 0.0013 117584 -> ord('b') ../trace.php:5 0.0014 117584 -> ret_ord($c = 'u') ../trace.php:10 0.0014 117584 -> ord('u') ../trace.php:5 0.0016 117584 -> ret_ord($c = 'g') ../trace.php:10 0.0016 117584 -> ord('g') ../trace.php:5 0.0019 41152 TRACE END [2007-05-06 14:37:16] Besides the xdebug.collect_params settings there is another number of settings that affect the output of trace files. The first tab "default" shows the same as the default as above. The second tab "show_mem_delta=1" also shows the memory usage difference between two different lines in the output file. On the "collect_return=1" tab the return values of all the function calls are also visible. This you turn on with the xdebug.collect_return setting. The tab called "collect_assignments=1" shows variable assigments, which can be turned on with the xdebug.collect_assignments setting. The last tab shows a different output format that is much easier to parse, but harder to read. The xdebug.trace_format setting is therefore mostly useful if there is an additional tool to interpret the trace files. TRACE START [2007-05-06 14:37:06] 0.0003 114112 -> {main}() ../trace.php:0 0.0004 114272 -> str_split() ../trace.php:8 0.0153 117424 -> ret_ord() ../trace.php:10 0.0165 117584 -> ord() ../trace.php:5 0.0166 117584 -> ret_ord() ../trace.php:10 0.0167 117584 -> ord() ../trace.php:5 0.0168 117584 -> ret_ord() ../trace.php:10 0.0168 117584 -> ord() ../trace.php:5 0.0170 117584 -> ret_ord() ../trace.php:10 0.0170 117584 -> ord() ../trace.php:5 0.0172 117584 -> ret_ord() ../trace.php:10 0.0172 117584 -> ord() ../trace.php:5 0.0173 117584 -> ret_ord() ../trace.php:10 0.0174 117584 -> ord() ../trace.php:5 0.0177 41152 TRACE END [2007-05-06 14:37:07] TRACE START [2007-05-06 14:37:26] 0.0003 114112 +114112 -> {main}() ../trace.php:0 0.0004 114272 +160 -> str_split('Xdebug') ../trace.php:8 0.0007 117424 +3152 -> ret_ord($c = 'X') ../trace.php:10 0.0007 117584 +160 -> ord('X') ../trace.php:5 0.0009 117584 +0 -> ret_ord($c = 'd') ../trace.php:10 0.0009 117584 +0 -> ord('d') ../trace.php:5 0.0011 117584 +0 -> ret_ord($c = 'e') ../trace.php:10 0.0011 117584 +0 -> ord('e') ../trace.php:5 0.0013 117584 +0 -> ret_ord($c = 'b') ../trace.php:10 0.0013 117584 +0 -> ord('b') ../trace.php:5 0.0014 117584 +0 -> ret_ord($c = 'u') ../trace.php:10 0.0015 117584 +0 -> ord('u') ../trace.php:5 0.0016 117584 +0 -> ret_ord($c = 'g') ../trace.php:10 0.0017 117584 +0 -> ord('g') ../trace.php:5 0.0019 41152 TRACE END [2007-05-06 14:37:26] TRACE START [2007-05-06 14:37:35] 0.0003 114112 -> {main}() ../trace.php:0 0.0004 114272 -> str_split('Xdebug') ../trace.php:8 >=> array (0 => 'X', 1 => 'd', 2 => 'e', 3 => 'b', 4 => 'u', 5 => 'g') 0.0007 117424 -> ret_ord($c = 'X') ../trace.php:10 0.0007 117584 -> ord('X') ../trace.php:5 >=> 88 >=> 88 0.0009 117584 -> ret_ord($c = 'd') ../trace.php:10 0.0009 117584 -> ord('d') ../trace.php:5 >=> 100 >=> 100 0.0011 117584 -> ret_ord($c = 'e') ../trace.php:10 0.0011 117584 -> ord('e') ../trace.php:5 >=> 101 >=> 101 0.0013 117584 -> ret_ord($c = 'b') ../trace.php:10 0.0013 117584 -> ord('b') ../trace.php:5 >=> 98 >=> 98 0.0015 117584 -> ret_ord($c = 'u') ../trace.php:10 0.0016 117584 -> ord('u') ../trace.php:5 >=> 117 >=> 117 0.0017 117584 -> ret_ord($c = 'g') ../trace.php:10 0.0018 117584 -> ord('g') ../trace.php:5 >=> 103 >=> 103 >=> 1 0.0021 41152 TRACE END [2007-05-06 14:37:35] Version: 2.0.0RC4-dev TRACE START [2007-05-06 18:29:01] 1 0 0 0.010870 114112 {main} 1 ../trace.php 0 2 1 0 0.032009 114272 str_split 0 ../trace.php 8 2 1 1 0.032073 116632 2 2 0 0.033505 117424 ret_ord 1 ../trace.php 10 3 3 0 0.033531 117584 ord 0 ../trace.php 5 3 3 1 0.033551 117584 2 2 1 0.033567 117584 2 4 0 0.033718 117584 ret_ord 1 ../trace.php 10 3 5 0 0.033740 117584 ord 0 ../trace.php 5 3 5 1 0.033758 117584 2 4 1 0.033770 117584 2 6 0 0.033914 117584 ret_ord 1 ../trace.php 10 3 7 0 0.033936 117584 ord 0 ../trace.php 5 3 7 1 0.033953 117584 2 6 1 0.033965 117584 2 8 0 0.034108 117584 ret_ord 1 ../trace.php 10 3 9 0 0.034130 117584 ord 0 ../trace.php 5 3 9 1 0.034147 117584 2 8 1 0.034160 117584 2 10 0 0.034302 117584 ret_ord 1 ../trace.php 10 3 11 0 0.034325 117584 ord 0 ../trace.php 5 3 11 1 0.034342 117584 2 10 1 0.034354 117584 2 12 0 0.034497 117584 ret_ord 1 ../trace.php 10 3 13 0 0.034519 117584 ord 0 ../trace.php 5 3 13 1 0.034536 117584 2 12 1 0.034549 117584 1 0 1 0.034636 117584 TRACE END [2007-05-06 18:29:01] VIM syntax fileXdebug ships with a VIM syntax file that syntax highlights the trace files: xt.vim. In order to make VIM recognise this new format you need to perform the following steps:
With those settings made an opened trace file looks like: TRACE START [2007-05-15 20:06:02] 0.0003 115208 -> {main}() ../trace.php:0 0.0004 115368 -> str_split() ../trace.php:8 0.0006 118520 -> ret_ord() ../trace.php:10 0.0007 118680 -> ord() ../trace.php:5 0.0008 118680 -> ret_ord() ../trace.php:10 0.0009 118680 -> ord() ../trace.php:5 0.0010 118680 -> ret_ord() ../trace.php:10 0.0010 118680 -> ord() ../trace.php:5 0.0012 118680 -> ret_ord() ../trace.php:10 0.0012 118680 -> ord() ../trace.php:5 0.0014 118680 -> ret_ord() ../trace.php:10 0.0014 118680 -> ord() ../trace.php:5 0.0016 118680 -> ret_ord() ../trace.php:10 0.0016 118680 -> ord() ../trace.php:5 0.0019 54880 TRACE END [2007-05-15 20:06:02] Folding also sorta works so you can use zc and zo to fold away parts of the trace files. Related Settingsxdebug.auto_trace
Type: boolean, Default value: 0
When this setting is set to on, the tracing of function calls will be
enabled just before the script is run. This makes it possible to trace code in
the auto_prepend_file.
xdebug.collect_assignments
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1
This setting, defaulting to 0, controls whether Xdebug should add
variable assignments to function traces.
xdebug.collect_includes
Type: boolean, Default value: 1
This setting, defaulting to 1, controls whether Xdebug should write the
filename used in include(), include_once(), require() or require_once() to the
trace files.
xdebug.collect_params
Type: integer, Default value: 0
This setting, defaulting to 0, controls whether Xdebug should collect the parameters passed to functions when a function call is recorded in either the function trace or the stack trace. The setting defaults to 0 because for very large scripts it may use huge amounts of memory and therefore make it impossible for the huge script to run. You can most safely turn this setting on, but you can expect some problems in scripts with a lot of function calls and/or huge data structures as parameters. Xdebug 2 will not have this problem with increased memory usage, as it will never store this information in memory. Instead it will only be written to disk. This means that you need to have a look at the disk usage though. This setting can have four different values. For each of the values a different amount of information is shown. Below you will see what information each of the values provides. See also the introduction of the feature Stack Traces for a few screenshots.
1 in the CLI version of PHP it will not have the tool tip, nor in output files. xdebug.collect_return
Type: boolean, Default value: 0
This setting, defaulting to 0, controls whether Xdebug should write the return value of function calls to the trace files. For computerized trace files (xdebug.trace_format=1) this only works from Xdebug 2.3 onwards. xdebug.show_mem_delta
Type: integer, Default value: 0
When this setting is set to something != 0 Xdebug's human-readable
generated trace files will show the difference in memory usage between function
calls. If Xdebug is configured to generate computer-readable trace files then
they will always show this information.
xdebug.trace_enable_trigger
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.2
When this setting is set to 1, you can trigger the generation of trace
files by using the XDEBUG_TRACE GET/POST parameter, or set a cookie with the
name XDEBUG_TRACE. This will then write the trace data to
defined directory. In order to prevent Xdebug
to generate trace files for each request, you need to set
xdebug.auto_trace to 0. Access to the trigger itself can be configured through
xdebug.trace_enable_trigger_value.
xdebug.trace_enable_trigger_value
Type: string, Default value: "", Introduced in Xdebug >= 2.3
This setting can be used to restrict who can make use of the
XDEBUG_TRACE functionality as outlined in xdebug.trace_enable_trigger. When
changed from its default value of an empty string, the value of the cookie,
GET or POST argument needs to match the shared secret set with this setting in
order for the trace file to be generated.
xdebug.trace_format
Type: integer, Default value: 0
The format of the trace file.
Fields for the computerized format:
See the introduction of Function Traces for a few examples. xdebug.trace_options
Type: integer, Default value: 0
When set to '1' the trace files will be appended to, instead of
being overwritten in subsequent requests.
xdebug.trace_output_dir
Type: string, Default value: /tmp
The directory where the tracing files will be written to, make sure that
the user who the PHP will be running as has write permissions to that
directory.
xdebug.trace_output_name
Type: string, Default value: trace.%c
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name. The '.xt' extension is always added automatically. The possible format specifiers are:
2 This one is not available for trace file names. 3 New in version 2.2. This one is set by Apache's mod_unique_id module xdebug.var_display_max_children
Type: integer, Default value: 128
Controls the amount of array children and object's properties are shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_data
Type: integer, Default value: 512
Controls the maximum string length that is shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_depth
Type: integer, Default value: 3
Controls how many nested levels of array elements and object properties are when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. The maximum value you can select is 1023. You can also use -1 as value to select this maximum number. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. Related Functionsstring xdebug_get_tracefile_name()
Returns the name of the function trace file
Returns the name of the file which is used to trace the output of this script too. This is useful when xdebug.auto_trace is enabled. string xdebug_start_trace( [ string trace_file [, integer options] ] )
Starts a new function trace
Start tracing function calls from this point to the file in the trace_file parameter. If no filename is given, then the trace file will be placed in the directory as configured by the xdebug.trace_output_dir setting. In case a file name is given as first parameter, the name is relative to the current working directory. This current working directory might be different than you expect it to be, so please use an absolute path in case you specify a file name. Use the PHP function getcwd() to figure out what the current working directory is. The name of the trace file is "{trace_file}.xt". If xdebug.auto_trace is enabled, then the format of the filename is "{filename}.xt" where the "{filename}" part depends on the xdebug.trace_output_name setting. The options parameter is a bitfield; currently there are three options:
The full path and filename to which Xdebug traces is returned from this function. This will be either the filename you pass in (potentially with ".xt" added), or the auto generated filename if no filename has been passed in. string xdebug_stop_trace()
Stops the current function trace
Stop tracing function calls and closes the trace file. The function returns the filename of the file where the trace was written to. Profiling PHP ScriptsXdebug's built-in profiler allows you to find bottlenecks in your script and visualize those with an external tool such as KCacheGrind or WinCacheGrind. IntroductionXdebug's Profiler is a powerful tool that gives you the ability to analyze your PHP code and determine bottlenecks or generally see which parts of your code are slow and could use a speed boost. The profiler in Xdebug 2 outputs profiling information in the form of a cachegrind compatible file. This allows you to use the excellent KCacheGrind tool (Linux, KDE) to analyse your profiling data. If you are on Linux you can install KCacheGrind with your favourite package manager. If you are on Windows, there are precompiled QCacheGrind binaries available. (QCacheGrind is KCacheGrind without KDE bindings). If you are on Mac OSX, there are instructions on how to build QCacheGrind too. Users of Windows can alternatively use WinCacheGrind. The functionality is different from KCacheGrind so the section that documents the use of KCacheGrind on this page doesn't apply to this program. WinCacheGrind currently does not support the file and function compression for cachegrind files that Xdebug 2.3 introduces yet. There is also an alternative profile information presentation tool called xdebugtoolkit, a web based front-end called Webgrind, and a Java based tool called XCallGraph. In case you can not use KDE (or do not want to use KDE) the kcachegrind package also comes with a perl script "ct_annotate" which produces ASCII output from the profiler trace files. Starting The ProfilerProfiling is enabled by setting the xdebug.profiler_enable setting to 1 in php.ini. This instructs Xdebug to start writing profiling information into the dump directory configured with the xdebug.profiler_output_dir directive. The name of the generated file always starts with "cachegrind.out." and ends with either the PID (process ID) of the PHP (or Apache) process or the crc32 hash of the directory containing the initially debugged script. Make sure you have enough space in your xdebug.profiler_output_dir as the amount of information generated by the profiler can be enormous for complex scripts, for example up to 500MB for a complex application like eZ Publish. You can also selectively enable the profiler with the xdebug.profiler_enable_trigger setting set to 1. If it is set to 1, then you can enable the profiler by using a GET/POST or COOKIE variable of the name XDEBUG_PROFILE. The FireFox 2 extension that can be used to enable the debugger (see HTTP Debug Sessions) can also be used with this setting. In order for the trigger to work properly, xdebug.profiler_enable needs to be set to 0. Analysing ProfilesAfter a profile information file has been generated you can open it with KCacheGrind: Once the file is opened you have plenty of information available in the
different panes of KCacheGrind. On the left side you find the "Flat Profile"
pane showing all functions in your script sorted by time spend in this function,
and all its children.
The pane on the right contains an upper and lower pane. The upper one
shows information about which functions called the current selected function
("eztemplatedesignresource->executecompiledtemplate in the screenshot).
The "Cost" column in the upper pane shows the time spend in the current selected function while being called from the function in the list. The numbers in the Cost column added up will always be 100%. The "Cost" column in the lower pane shows the time spend while calling the function from the list. While adding the numbers in this list up, you will most likely never reach 100% as the selected function itself will also takes time to execute. The "All Callers" and "All Calls" tabs show not only the direct call from
Related Settingsxdebug.profiler_aggregate
Type: integer, Default value: 0
When this setting is set to 1, a single profiler file will be written
for multiple requests. One can surf to multiple pages or reload a page
to get an average across all requests. The file will be named
.cachegrind.aggregate . You will need to move this file to get
another round of aggregate data.xdebug.profiler_append
Type: integer, Default value: 0
When this setting is set to 1, profiler files will not be overwritten when
a new request would map to the same file (depending on the xdebug.profiler_output_name setting.
Instead the file will be appended to with the new profile.
xdebug.profiler_enable
Type: integer, Default value: 0
Enables Xdebug's profiler which creates files in the
profile output directory. Those files can be
read by KCacheGrind to visualize your data. This setting can not be set in
your script with ini_set(). If you want to selectively enable the profiler,
please set xdebug.profiler_enable_trigger to 1 instead of using
this setting.
xdebug.profiler_enable_trigger
Type: integer, Default value: 0
When this setting is set to 1, you can trigger the generation of profiler
files by using the XDEBUG_PROFILE GET/POST parameter, or set a cookie with the
name XDEBUG_PROFILE. This will then write the profiler data to
defined directory. In order to prevent the profiler
to generate profile files for each request, you need to set
xdebug.profiler_enable to 0. Access to the trigger itself can be configured
through xdebug.profiler_enable_trigger_value.
xdebug.profiler_enable_trigger_value
Type: string, Default value: "", Introduced in Xdebug >= 2.3
This setting can be used to restrict who can make use of the
XDEBUG_PROFILE functionality as outlined in xdebug.profiler_enable_trigger. When
changed from its default value of an empty string, the value of the cookie,
GET or POST argument needs to match the shared secret set with this setting in order
for the profiler to start.
xdebug.profiler_output_dir
Type: string, Default value: /tmp
The directory where the profiler output will be written to, make sure that
the user who the PHP will be running as has write permissions to that
directory. This setting can not be set in your script with ini_set().
xdebug.profiler_output_name
Type: string, Default value: cachegrind.out.%p
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name. See the xdebug.trace_output_name documentation for the supported specifiers. Related Functionsstring xdebug_get_profiler_filename()
Returns the profile information filename
Returns the name of the file which is used to save profile information to. Remote DebuggingXdebug provides an interface for debugger clients that interact with running PHP scripts. This section explains how to set-up PHP and Xdebug to allow this, and introduces a few clients. IntroductionXdebug's (remote) debugger allows you to examine data structure, interactively walk through your and debug your code. The protocol that is being used is open, and is called DBGp. This protocol is implemented in Xdebug 2, and replaces an older GDB-like protocol that is no longer supported. ClientsXdebug 2 is bundled with a simple command line client for the DBGp protocol. There are a few other client implementations (both free and commercial) as well. I am not the author of any of those, so please refer to the original authors for support:
A simple command line client for debugging is bundled with Xdebug in the
Starting The DebuggerIn order to enable Xdebug's debugger you need to make some configuration settings in php.ini. These settings are xdebug.remote_enable to enable the debugger, xdebug.remote_host and xdebug.remote_port to configure the IP address and port where the debugger should connect to. There is also a xdebug.remote_connect_back setting that can be used if your development server is shared with multiple developers. If you want the debugger to initiate a session when an error situation occurs (PHP error or exception) then you also need to change the xdebug.remote_mode setting. Allowed values for this setting are "req" (the default) which makes the debugger initiate a session as soon as a script is started, or "jit" when a session should only be initiated on an error. After made all those settings Xdebug will still not start a debugging session automatically when a script is run. You need to activate Xdebug's debugger and you can do that in three ways:
Before you start your script you will need to tell your client that it can receive debug connections, please refer to the documentation of the specific client on how to do this. To use the bundled client simply start it after compiling and installing it. You can start it by running "debugclient". When the debugclient starts it will show the following information and then waits until a connection is initiated by the debug server: Xdebug Simple DBGp client (0.10.0) Copyright 2002-2007 by Derick Rethans. - libedit support: enabled Waiting for debug server to connect. After a connection is made the output of the debug server is shown: Connect <?xml version="1.0" encoding="iso-8859-1"?> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/httpd/www.xdebug.org/html/docs/index.php" language="PHP" protocol_version="1.0" appid="13202" idekey="derick"> <engine version="2.0.0RC4-dev"><![CDATA[Xdebug]]></engine> <author><![CDATA[Derick Rethans]]></author> <url><![CDATA[http://xdebug.org]]></url> <copyright><![CDATA[Copyright (c) 2002-2007 by Derick Rethans]]></copyright> </init> (cmd) Now you can use the commandset as explained on the DBGp documentation page. When the script ends the debug server disconnects from the client and the debugclient resumes with waiting for a new connection. Communication Set-upWith a static IP/single developerWith remote debugging, Xdebug embedded in PHP acts like the client, and the IDE as the server. The following animation shows how the communication channel is set-up:
With an unknown IP/multiple developersIf xdebug.remote_connect_back is used, the set-up is slightly different:
HTTP Debug SessionsXdebug contains functionality to keep track of a debug session when started through a browser: cookies. This works like this:
Multiple Users DebuggingXdebug only allows you to specify one IP address to connect to with xdebug.remote_host) while doing remote debugging. It does not automatically connect back to the IP address of the machine the browser runs on, unless you use xdebug.remote_connect_back.
If all of your developers work on different projects on the same (development)
server, you can make the xdebug.remote_host setting for each directory
through Apache's .htaccess functionality by using There are two solutions to this. First of all, you can use a DBGp proxy. For an overview on how to use this proxy, please refer to the article at Debugging with multiple users. You can download the proxy on ActiveState's web site as part of the python remote debugging package. There is some more documentation in the Komodo FAQ. Secondly you can use the xdebug.remote_connect_back setting that was introduced in Xdebug 2.1. Implementation Details
Xdebug's implementation of the
DBGp protocol's Related Settingsxdebug.extended_info
Type: integer, Default value: 1
Controls whether Xdebug should enforce 'extended_info' mode for the PHP
parser; this allows Xdebug to do file/line breakpoints with the remote
debugger. When tracing or profiling scripts you generally want to turn off this
option as PHP's generated oparrays will increase with about a third of the size
slowing down your scripts. This setting can not be set in your scripts with
ini_set(), but only in php.ini.
xdebug.idekey
Type: string, Default value: *complex*
Controls which IDE Key Xdebug should pass on to the DBGp debugger handler.
The default is based on environment settings. First the environment setting
DBGP_IDEKEY is consulted, then USER and as last USERNAME. The default is set
to the first environment variable that is found. If none could be found the
setting has as default ''. If this setting is set, it always overrides
the environment variables.
xdebug.remote_addr_header
Type: string, Default value: "", Introduced in Xdebug >= 2.4
If xdebug.remote_addr_header is configured to be a non-empty string, then
the value is used as key in the $SERVER superglobal array to determine which
header to use to find the IP address or hostname to use for 'connecting back
to'. This setting is only used in combination with xdebug.remote_connect_back
and is otherwise ignored.
xdebug.remote_autostart
Type: boolean, Default value: 0
Normally you need to use a specific HTTP GET/POST variable to start
remote debugging (see Remote Debugging). When
this setting is set to 1, Xdebug will always attempt to start a remote
debugging session and try to connect to a client, even if the GET/POST/COOKIE
variable was not present.
xdebug.remote_connect_back
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1
If enabled, the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request. It checks the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables to find out which IP address to use. If xdebug.remote_addr_header is configured, then the $SERVER variable with the configured name will be checked before the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables. This setting does not apply for debugging through the CLI, as the $SERVER header variables are not available there. Please note that there is no filter available, and anybody who can connect to the webserver will then be able to start a debugging session, even if their address does not match xdebug.remote_host. xdebug.remote_cookie_expire_time
Type: integer, Default value: 3600, Introduced in Xdebug >= 2.1
This setting can be used to increase (or decrease) the time that the
remote debugging session stays alive via the session cookie.
xdebug.remote_enable
Type: boolean, Default value: 0
This switch controls whether Xdebug should try to contact a debug client
which is listening on the host and port as set with the settings
xdebug.remote_host and
xdebug.remote_port. If a connection can not be established the script will just
continue as if this setting was 0.
xdebug.remote_handler
Type: string, Default value: dbgp
Can be either 'php3' which selects the old PHP 3 style debugger output, 'gdb' which enables the GDB like debugger interface or 'dbgp' - the debugger protocol. The DBGp protocol is the only supported protocol. Note: Xdebug 2.1 and later only support 'dbgp' as protocol. xdebug.remote_host
Type: string, Default value: localhost
Selects the host where the debug client is running, you can either use a host name, IP address, or 'unix:///path/to/sock' for a Unix domain socket. This setting is ignored if xdebug.remote_connect_back is enabled. Support for Unix domain sockets was introduced in Xdebug 2.6. xdebug.remote_log
Type: string, Default value:
If set to a value, it is used as filename to a file to which all remote
debugger communications are logged. The file is always opened in append-mode,
and will therefore not be overwritten by default. There is no concurrency
protection available. The format of the file looks something like:
Log opened at 2007-05-27 14:28:15 -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/x ... ight></init> <- step_into -i 1 -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/db ... ></response> xdebug.remote_mode
Type: string, Default value: req
Selects when a debug connection is initiated. This setting can have two different values:
xdebug.remote_port
Type: integer, Default value: 9000
The port to which Xdebug tries to connect on the remote host. Port
9000 is the default for both the client and the bundled debugclient.
As many clients use this port number, it is best to leave this setting
unchanged.
Related Functionsbool xdebug_break()
Emits a breakpoint to the debug client.
This function makes the debugger break on the specific line as if a normal file/line breakpoint was set on this line. Code Coverage AnalysisCode coverage tells you which lines of script (or set of scripts) have been executed during a request. With this information you can for example find out how good your unit tests are. Related Settingsxdebug.coverage_enable
Type: boolean, Default value: 1, Introduced in Xdebug >= 2.2
If this setting is set to 0, then Xdebug will not set-up internal
structures to allow code coverage. This speeds up Xdebug quite a bit,
but of course, Code Coverage Analysis won't work.
Related Functionsboolean xdebug_code_coverage_started()
Returns whether code coverage is active.
Returns whether code coverage has been started. Example:
<?php Returns:
bool(false) bool(true) array xdebug_get_code_coverage()
Returns code coverage information
Returns a structure which contains information about which lines were executed in your script (including include files). The following example shows code coverage for one specific file: Example:
<?php Returns:
array '/home/httpd/html/test/xdebug/docs/xdebug_get_code_coverage.php' => array 5 => int 1 6 => int 1 7 => int 1 9 => int 1 10 => int 1 11 => int 1 12 => int 1 13 => int 1 15 => int 1 16 => int 1 18 => int 1 void xdebug_start_code_coverage( [int options] )
Starts code coverage
This function starts gathering the information for code coverage. The information that is collected consists of an two dimensional array with as primary index the executed filename and as secondary key the line number. The value in the elements represents whether the line has been executed or whether it has unreachable lines. The returned values for each line are:
-1 is only returned when the XDEBUG_CC_UNUSED
is enabled and value -2 is only returned when both
XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE are enabled.
This function has two options, which act as a bitfield:
You can use the options as shown in the following example. Example:
<?php void xdebug_stop_code_coverage( [int cleanup=true] )
Stops code coverage
This function stops collecting information, the information in memory will be destroyed. If you pass "false" as argument, then the code coverage information will not be destroyed so that you can resume the gathering of information with the xdebug_start_code_coverage() function again. FAQFrequently Asked Questions Using Xdebug
Compilation and Configuration
ReferenceRelated Settingsxdebug.auto_trace
Type: boolean, Default value: 0
When this setting is set to on, the tracing of function calls will be
enabled just before the script is run. This makes it possible to trace code in
the auto_prepend_file.
xdebug.cli_color
Type: integer, Default value: 0, Introduced in Xdebug >= 2.2
If this setting is 1, Xdebug will color var_dumps and stack traces output when in CLI mode and when the output is a tty. On Windows, the ANSICON tool needs to be installed. If the setting is 2, then Xdebug will always color var_dumps and stack trace, no matter whether it's connected to a tty or whether ANSICON is installed. In this case, you might end up seeing escape codes. See this article for some more information. xdebug.collect_assignments
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1
This setting, defaulting to 0, controls whether Xdebug should add
variable assignments to function traces.
xdebug.collect_includes
Type: boolean, Default value: 1
This setting, defaulting to 1, controls whether Xdebug should write the
filename used in include(), include_once(), require() or require_once() to the
trace files.
xdebug.collect_params
Type: integer, Default value: 0
This setting, defaulting to 0, controls whether Xdebug should collect the parameters passed to functions when a function call is recorded in either the function trace or the stack trace. The setting defaults to 0 because for very large scripts it may use huge amounts of memory and therefore make it impossible for the huge script to run. You can most safely turn this setting on, but you can expect some problems in scripts with a lot of function calls and/or huge data structures as parameters. Xdebug 2 will not have this problem with increased memory usage, as it will never store this information in memory. Instead it will only be written to disk. This means that you need to have a look at the disk usage though. This setting can have four different values. For each of the values a different amount of information is shown. Below you will see what information each of the values provides. See also the introduction of the feature Stack Traces for a few screenshots.
1 in the CLI version of PHP it will not have the tool tip, nor in output files. xdebug.collect_return
Type: boolean, Default value: 0
This setting, defaulting to 0, controls whether Xdebug should write the return value of function calls to the trace files. For computerized trace files (xdebug.trace_format=1) this only works from Xdebug 2.3 onwards. xdebug.collect_vars
Type: boolean, Default value: 0
This setting tells Xdebug to gather information about which variables
are used in a certain scope. This analysis can be quite slow as Xdebug has
to reverse engineer PHP's opcode arrays. This setting will not record which
values the different variables have, for that use xdebug.collect_params.
This setting needs to be enabled only if you wish to use
xdebug_get_declared_vars().
xdebug.coverage_enable
Type: boolean, Default value: 1, Introduced in Xdebug >= 2.2
If this setting is set to 0, then Xdebug will not set-up internal
structures to allow code coverage. This speeds up Xdebug quite a bit,
but of course, Code Coverage Analysis won't work.
xdebug.default_enable
Type: boolean, Default value: 1
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.
xdebug.dump.*
Type: string, Default value: Empty
* can be any of COOKIE, FILES, GET, POST, REQUEST, SERVER, SESSION. These seven settings control which data from the superglobals is shown when an error situation occurs. Each of those php.ini setting can consist of a comma seperated list of
variables from this superglobal to dump, or In order to dump the REMOTE_ADDR and the REQUEST_METHOD when an error occurs, and all GET parameters, add these settings: xdebug.dump.SERVER = REMOTE_ADDR,REQUEST_METHOD xdebug.dump.GET = * xdebug.dump_globals
Type: boolean, Default value: 1
Controls whether the values of the superglobals as defined by the xdebug.dump.* settings should be shown or not.
xdebug.dump_once
Type: boolean, Default value: 1
Controls whether the values of the superglobals should be dumped on all
error situations (set to 0) or only on the first (set to 1).
xdebug.dump_undefined
Type: boolean, Default value: 0
If you want to dump undefined values from the superglobals you should set
this setting to 1, otherwise leave it set to 0.
xdebug.extended_info
Type: integer, Default value: 1
Controls whether Xdebug should enforce 'extended_info' mode for the PHP
parser; this allows Xdebug to do file/line breakpoints with the remote
debugger. When tracing or profiling scripts you generally want to turn off this
option as PHP's generated oparrays will increase with about a third of the size
slowing down your scripts. This setting can not be set in your scripts with
ini_set(), but only in php.ini.
xdebug.file_link_format
Type: string, Default value: , Introduced in Xdebug >= 2.1
This setting determines the format of the links that are made in the display of stack traces where file names are used. This allows IDEs to set up a link-protocol that makes it possible to go directly to a line and file by clicking on the filenames that Xdebug shows in stack traces. An example format might look like: myide://%f@%l The possible format specifiers are:
For various IDEs/OSses there are some instructions listed on how to make this work: Firefox on Linux
Windows and netbeans
xdebug.force_display_errors
Type: int, Default value: 0, Introduced in Xdebug >= 2.3
If this setting is set to xdebug.force_error_reporting
Type: int, Default value: 0, Introduced in Xdebug >= 2.3
This setting is a bitmask, like error_reporting. This bitmask will be logically ORed with the bitmask represented by error_reporting to dermine which errors should be displayed. This setting can only be made in php.ini and allows you to force certain errors from being shown no matter what an application does with ini_set(). xdebug.halt_level
Type: int, Default value: 0, Introduced in Xdebug >= 2.3
This setting allows you to configure a mask that determines whether, and which, notices and/or warnings get converted to errors. You can configure notices and warnings that are generated by PHP, and notices and warnings that you generate yourself (by means of trigger_error()). For example, to convert the warning of strlen() (without arguments) to an error, you would do: ini_set('xdebug.halt_level', E_WARNING); strlen(); echo "Hi!\n"; Which will then result in the showing of the error message, and the abortion
of the script. The setting is a bit mask, so to convert all notices and warnings into errors for all applications, you can set this in php.ini: xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE The bitmask only supports the four level that are mentioned above. xdebug.idekey
Type: string, Default value: *complex*
Controls which IDE Key Xdebug should pass on to the DBGp debugger handler.
The default is based on environment settings. First the environment setting
DBGP_IDEKEY is consulted, then USER and as last USERNAME. The default is set
to the first environment variable that is found. If none could be found the
setting has as default ''. If this setting is set, it always overrides
the environment variables.
xdebug.manual_url
Type: string, Default value: http://www.php.net, Introduced in Xdebug < 2.2.1
This is the base url for the links from the function traces and error
message to the manual pages of the function from the message. It is advisable
to set this setting to use the closest mirror.
xdebug.max_nesting_level
Type: integer, Default value: 256
Controls the protection mechanism for infinite recursion protection. The value of this setting is the maximum level of nested functions that are allowed before the script will be aborted. Before Xdebug 2.3, the default value was xdebug.max_stack_frames
Type: integer, Default value: -1, Introduced in Xdebug >= 2.3
Controls how many stack frames are shown in stack traces, both on the command line during PHP error stack traces, as well as in the browser for HTML traces. xdebug.overload_var_dump
Type: boolean, Default value: 2, Introduced in Xdebug > 2.1
By default Xdebug overloads var_dump() with its own improved version
for displaying variables when the html_errors php.ini setting is set to
You can also use Before Xdebug 2.4, the default value of this setting was
xdebug.profiler_aggregate
Type: integer, Default value: 0
When this setting is set to 1, a single profiler file will be written
for multiple requests. One can surf to multiple pages or reload a page
to get an average across all requests. The file will be named
.cachegrind.aggregate . You will need to move this file to get
another round of aggregate data.xdebug.profiler_append
Type: integer, Default value: 0
When this setting is set to 1, profiler files will not be overwritten when
a new request would map to the same file (depending on the xdebug.profiler_output_name setting.
Instead the file will be appended to with the new profile.
xdebug.profiler_enable
Type: integer, Default value: 0
Enables Xdebug's profiler which creates files in the
profile output directory. Those files can be
read by KCacheGrind to visualize your data. This setting can not be set in
your script with ini_set(). If you want to selectively enable the profiler,
please set xdebug.profiler_enable_trigger to 1 instead of using
this setting.
xdebug.profiler_enable_trigger
Type: integer, Default value: 0
When this setting is set to 1, you can trigger the generation of profiler
files by using the XDEBUG_PROFILE GET/POST parameter, or set a cookie with the
name XDEBUG_PROFILE. This will then write the profiler data to
defined directory. In order to prevent the profiler
to generate profile files for each request, you need to set
xdebug.profiler_enable to 0. Access to the trigger itself can be configured
through xdebug.profiler_enable_trigger_value.
xdebug.profiler_enable_trigger_value
Type: string, Default value: "", Introduced in Xdebug >= 2.3
This setting can be used to restrict who can make use of the
XDEBUG_PROFILE functionality as outlined in xdebug.profiler_enable_trigger. When
changed from its default value of an empty string, the value of the cookie,
GET or POST argument needs to match the shared secret set with this setting in order
for the profiler to start.
xdebug.profiler_output_dir
Type: string, Default value: /tmp
The directory where the profiler output will be written to, make sure that
the user who the PHP will be running as has write permissions to that
directory. This setting can not be set in your script with ini_set().
xdebug.profiler_output_name
Type: string, Default value: cachegrind.out.%p
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name. See the xdebug.trace_output_name documentation for the supported specifiers. xdebug.remote_addr_header
Type: string, Default value: "", Introduced in Xdebug >= 2.4
If xdebug.remote_addr_header is configured to be a non-empty string, then
the value is used as key in the $SERVER superglobal array to determine which
header to use to find the IP address or hostname to use for 'connecting back
to'. This setting is only used in combination with xdebug.remote_connect_back
and is otherwise ignored.
xdebug.remote_autostart
Type: boolean, Default value: 0
Normally you need to use a specific HTTP GET/POST variable to start
remote debugging (see Remote Debugging). When
this setting is set to 1, Xdebug will always attempt to start a remote
debugging session and try to connect to a client, even if the GET/POST/COOKIE
variable was not present.
xdebug.remote_connect_back
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1
If enabled, the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request. It checks the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables to find out which IP address to use. If xdebug.remote_addr_header is configured, then the $SERVER variable with the configured name will be checked before the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables. This setting does not apply for debugging through the CLI, as the $SERVER header variables are not available there. Please note that there is no filter available, and anybody who can connect to the webserver will then be able to start a debugging session, even if their address does not match xdebug.remote_host. xdebug.remote_cookie_expire_time
Type: integer, Default value: 3600, Introduced in Xdebug >= 2.1
This setting can be used to increase (or decrease) the time that the
remote debugging session stays alive via the session cookie.
xdebug.remote_enable
Type: boolean, Default value: 0
This switch controls whether Xdebug should try to contact a debug client
which is listening on the host and port as set with the settings
xdebug.remote_host and
xdebug.remote_port. If a connection can not be established the script will just
continue as if this setting was 0.
xdebug.remote_handler
Type: string, Default value: dbgp
Can be either 'php3' which selects the old PHP 3 style debugger output, 'gdb' which enables the GDB like debugger interface or 'dbgp' - the debugger protocol. The DBGp protocol is the only supported protocol. Note: Xdebug 2.1 and later only support 'dbgp' as protocol. xdebug.remote_host
Type: string, Default value: localhost
Selects the host where the debug client is running, you can either use a host name, IP address, or 'unix:///path/to/sock' for a Unix domain socket. This setting is ignored if xdebug.remote_connect_back is enabled. Support for Unix domain sockets was introduced in Xdebug 2.6. xdebug.remote_log
Type: string, Default value:
If set to a value, it is used as filename to a file to which all remote
debugger communications are logged. The file is always opened in append-mode,
and will therefore not be overwritten by default. There is no concurrency
protection available. The format of the file looks something like:
Log opened at 2007-05-27 14:28:15 -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/x ... ight></init> <- step_into -i 1 -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/db ... ></response> xdebug.remote_mode
Type: string, Default value: req
Selects when a debug connection is initiated. This setting can have two different values:
xdebug.remote_port
Type: integer, Default value: 9000
The port to which Xdebug tries to connect on the remote host. Port
9000 is the default for both the client and the bundled debugclient.
As many clients use this port number, it is best to leave this setting
unchanged.
xdebug.scream
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.1
If this setting is 1, then Xdebug will disable the @ (shut-up)
operator so that notices, warnings and errors are no longer hidden.
xdebug.show_error_trace
Type: integer, Default value: 0, Introduced in Xdebug >= 2.4
When this setting is set to 1, Xdebug will show a stack trace whenever
an Error is raised - even if this Error is actually caught.
xdebug.show_exception_trace
Type: integer, Default value: 0
When this setting is set to 1, Xdebug will show a stack trace whenever an Exception or Error is raised - even if this Exception or Error is actually caught. Error 'exceptions' were introduced in PHP 7. xdebug.show_local_vars
Type: integer, Default value: 0
When this setting is set to something != 0 Xdebug's generated stack dumps
in error situations will also show all variables in the top-most scope. Beware
that this might generate a lot of information, and is therefore turned off by
default.
xdebug.show_mem_delta
Type: integer, Default value: 0
When this setting is set to something != 0 Xdebug's human-readable
generated trace files will show the difference in memory usage between function
calls. If Xdebug is configured to generate computer-readable trace files then
they will always show this information.
xdebug.trace_enable_trigger
Type: boolean, Default value: 0, Introduced in Xdebug >= 2.2
When this setting is set to 1, you can trigger the generation of trace
files by using the XDEBUG_TRACE GET/POST parameter, or set a cookie with the
name XDEBUG_TRACE. This will then write the trace data to
defined directory. In order to prevent Xdebug
to generate trace files for each request, you need to set
xdebug.auto_trace to 0. Access to the trigger itself can be configured through
xdebug.trace_enable_trigger_value.
xdebug.trace_enable_trigger_value
Type: string, Default value: "", Introduced in Xdebug >= 2.3
This setting can be used to restrict who can make use of the
XDEBUG_TRACE functionality as outlined in xdebug.trace_enable_trigger. When
changed from its default value of an empty string, the value of the cookie,
GET or POST argument needs to match the shared secret set with this setting in
order for the trace file to be generated.
xdebug.trace_format
Type: integer, Default value: 0
The format of the trace file.
Fields for the computerized format:
See the introduction of Function Traces for a few examples. xdebug.trace_options
Type: integer, Default value: 0
When set to '1' the trace files will be appended to, instead of
being overwritten in subsequent requests.
xdebug.trace_output_dir
Type: string, Default value: /tmp
The directory where the tracing files will be written to, make sure that
the user who the PHP will be running as has write permissions to that
directory.
xdebug.trace_output_name
Type: string, Default value: trace.%c
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name. The '.xt' extension is always added automatically. The possible format specifiers are:
2 This one is not available for trace file names. 3 New in version 2.2. This one is set by Apache's mod_unique_id module xdebug.var_display_max_children
Type: integer, Default value: 128
Controls the amount of array children and object's properties are shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_data
Type: integer, Default value: 512
Controls the maximum string length that is shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. To disable any limitation, use -1 as value. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. xdebug.var_display_max_depth
Type: integer, Default value: 3
Controls how many nested levels of array elements and object properties are when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces. The maximum value you can select is 1023. You can also use -1 as value to select this maximum number. This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature. Related Functionsvoid var_dump( [mixed var [, ...]] )
Displays detailed information about a variable
This function is overloaded by Xdebug, see the description for xdebug_var_dump(). bool xdebug_break()
Emits a breakpoint to the debug client.
This function makes the debugger break on the specific line as if a normal file/line breakpoint was set on this line. string xdebug_call_class( [int $depth = 1] )
Returns the calling class,
NULL if the stack frame does not exist, or FALSE if the stack frame has no class information
This function returns the name of the class that defined the current method, or
Example:
<?php Returns:
Called @ /home/httpd/html/test/xdebug_caller.php:17 from ::{main}
To retrieve information from earlier stack frames, use the optional
Example:
<?php Returns:
Strings::fix_string is called at /home/httpd/html/test/xdebug_caller:17
A value of Example:
<?php Returns:
Strings::fix_strings is called at /home/httpd/html/test/xdebug_caller:25
A value of Example:
<?php Returns:
::xdebug_call_function is called at /home/httpd/html/test/xdebug_caller:13 string xdebug_call_file( [int $depth = 1] )
Returns the calling file, or
NULL if the stack frame does not existThis function returns the filename from where the current function/method was executed from.
To retrieve information from earlier stack frames, use the optional
For examples and more extensive information, see xdebug_call_class(). string xdebug_call_function( [int $depth = 1] )
Returns the calling function/method,
NULL if the stack frame does not exist, or FALSE if the stack frame has no function/method informationThis function returns the name of the current function/method.
To retrieve information from earlier stack frames, use the optional
For examples and more extensive information, see xdebug_call_class(). int xdebug_call_line( [int $depth = 1] )
Returns the calling line number, or
NULL if the stack frame does not existThis function returns the line number from where the current function/method was called from.
To retrieve information from earlier stack frames, use the optional
For examples and more extensive information, see xdebug_call_class(). boolean xdebug_code_coverage_started()
Returns whether code coverage is active.
Returns whether code coverage has been started. Example:
<?php Returns:
bool(false) bool(true) void xdebug_debug_zval( [string varname [, ...]] )
Displays information about a variable
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. This function is implemented differently from PHP's debug_zval_dump() function in order to work around the problems that that function has because the variable itself is actually passed to the function. Xdebug's version is better as it uses the variable name to lookup the variable in the internal symbol table and accesses all the properties directly without having to deal with actually passing a variable to a function. The result is that the information that this function returns is much more accurate than PHP's own function for showing zval information. Support for anything but simple variable names (such as "a[2]" below) is supported since Xdebug 2.3. Example:
<?php Returns:
a: (refcount=2, is_ref=1)=array ( 0 => (refcount=1, is_ref=0)=1, 1 => (refcount=1, is_ref=0)=2, 2 => (refcount=2, is_ref=1)=3) a[2]: (refcount=2, is_ref=1)=3 void xdebug_debug_zval_stdout( [string varname [, ...]] )
Returns information about variables to stdout.
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. The difference with xdebug_debug_zval() is that the information is not displayed through a web server API layer, but directly shown on stdout (so that when you run it with Apache in single process mode it ends up on the console). Example:
<?php Returns:
a: (refcount=2, is_ref=1)=array ( 0 => (refcount=1, is_ref=0)=1, 1 => (refcount=1, is_ref=0)=2, 2 => (refcount=2, is_ref=1)=3) void xdebug_disable()
Disables stack traces
Disable showing stack traces on error conditions. void xdebug_dump_superglobals()
Displays information about super globals
This function dumps the values of the elements of the super globals as specified with the xdebug.dump.* php.ini settings. For the example below the settings in php.ini are: Example:
xdebug.dump.GET=* Returns:
void xdebug_enable()
Enables stack traces
Enable showing stack traces on error conditions. array xdebug_get_code_coverage()
Returns code coverage information
Returns a structure which contains information about which lines were executed in your script (including include files). The following example shows code coverage for one specific file: Example:
<?php Returns:
array '/home/httpd/html/test/xdebug/docs/xdebug_get_code_coverage.php' => array 5 => int 1 6 => int 1 7 => int 1 9 => int 1 10 => int 1 11 => int 1 12 => int 1 13 => int 1 15 => int 1 16 => int 1 18 => int 1 string xdebug_get_collected_errors( [int clean] )
Returns all collected error messages
Introduced in version 2.1
This function returns all errors from the collection buffer that contains all errors that were stored there when error collection was started with xdebug_start_error_collection().
By default this function will not clear the error collection buffer. If you pass
This function returns a string containing all collected errors formatted as an "Xdebug table". array xdebug_get_declared_vars()
Returns declared variables
Returns an array where each element is a variable name which is defined in the current scope. The setting xdebug.collect_vars needs to be enabled. Example:
<?php Returns:
array 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'item' (length=4) In PHP versions before 5.1, the variable name "a" is not in the returned array, as it is not used in the scope where the function xdebug_get_declared_vars() is called in. array xdebug_get_function_stack()
Returns information about the stack
Returns an array which resembles the stack trace up to this point. The example script: Example:
<?php Returns:
array 0 => array 'function' => string '{main}' (length=6) 'file' => string '/var/www/xdebug_get_function_stack.php' (length=63) 'line' => int 0 'params' => array empty 1 => array 'function' => string 'fix_strings' (length=11) 'class' => string 'strings' (length=7) 'file' => string '/var/www/xdebug_get_function_stack.php' (length=63) 'line' => int 18 'params' => array 'b' => string 'array (0 => 'Derick')' (length=21) 2 => array 'function' => string 'fix_string' (length=10) 'class' => string 'strings' (length=7) 'file' => string '/var/www/xdebug_get_function_stack.php' (length=63) 'line' => int 12 'params' => array 'a' => string ''Derick'' (length=8) array xdebug_get_headers()
Returns all the headers as set by calls to PHP's header() function
Introduced in version 2.1
Returns all the headers that are set with PHP's header() function, or any other header set internally within PHP (such as through setcookie()), as an array. Example:
<?php Returns:
array(2) { [0]=> string(6) "X-Test" [1]=> string(33) "Set-Cookie: TestCookie=test-value" } array xdebug_get_monitored_functions()
Returns information about monitored functions
Introduced in version 2.4
Returns a structure which contains information about where the monitored functions were executed in your script. The following example shows how to use this, and the returned information: Example:
<?php Returns:
/tmp/monitor-example.php:10: array(2) { [0] => array(3) { 'function' => string(6) "strrev" 'filename' => string(24) "/tmp/monitor-example.php" 'lineno' => int(6) } [1] => array(3) { 'function' => string(6) "strrev" 'filename' => string(24) "/tmp/monitor-example.php" 'lineno' => int(8) } } string xdebug_get_profiler_filename()
Returns the profile information filename
Returns the name of the file which is used to save profile information to. integer xdebug_get_stack_depth()
Returns the current stack depth level
Returns the stack depth level. The main body of a script is level 0 and each include and/or function call adds one to the stack depth level. string xdebug_get_tracefile_name()
Returns the name of the function trace file
Returns the name of the file which is used to trace the output of this script too. This is useful when xdebug.auto_trace is enabled. bool xdebug_is_enabled()
Returns whether stack traces are enabled
Return whether stack traces would be shown in case of an error or not. int xdebug_memory_usage()
Returns the current memory usage
Returns the current amount of memory the script uses. Before PHP 5.2.1, this only works if PHP is compiled with --enable-memory-limit. From PHP 5.2.1 and later this function is always available. int xdebug_peak_memory_usage()
Returns the peak memory usage
Returns the maximum amount of memory the script used until now. Before PHP 5.2.1, this only works if PHP is compiled with --enable-memory-limit. From PHP 5.2.1 and later this function is always available. none xdebug_print_function_stack( [ string message [, int options ] ] )
Displays the current function stack.
Displays the current function stack, in a similar way as what Xdebug would display in an error situation. The "message" argument allows you to replace the message in the header with your own. (Introduced in Xdebug 2.1). Example:
<?php Returns:
The bitmask "options" allows you to configure a few extra options. The following options are currently supported:
void xdebug_start_code_coverage( [int options] )
Starts code coverage
This function starts gathering the information for code coverage. The information that is collected consists of an two dimensional array with as primary index the executed filename and as secondary key the line number. The value in the elements represents whether the line has been executed or whether it has unreachable lines. The returned values for each line are:
-1 is only returned when the XDEBUG_CC_UNUSED
is enabled and value -2 is only returned when both
XDEBUG_CC_UNUSED and XDEBUG_CC_DEAD_CODE are enabled.
This function has two options, which act as a bitfield:
You can use the options as shown in the following example. Example:
<?php void xdebug_start_error_collection()
Starts recording all notices, warnings and errors and prevents their display
Introduced in version 2.1
When this function is executed, Xdebug will cause PHP not to display any notices, warnings or errors. Instead, they are formatted according to Xdebug's normal error formatting rules (ie, the error table with the red exclamation mark) and then stored in a buffer. This will continue until you call xdebug_stop_error_collection(). This buffer's contents can be retrieved by calling xdebug_get_collected_errors() and then subsequently displayed. This is really useful if you want to prevent Xdebug's powerful error reporting features from destroying your layout. void xdebug_start_function_monitor( array $list_of_functions_to_monitor )
Starts function monitoring
Introduced in version 2.4
This function starts the monitoring of functions that were given in a list as argument to this function. Function monitoring allows you to find out where in your code the functions that you provided as argument are called from. This can be used to track where old, or, discouraged functions are used. Example:
<?php You can also add class methods and static methods to the array that defines which functions to monitor. For example, to catch static calls to DramModel::canSee and dynamic calls to Whisky->drink, you would start the monitor with: Example:
<?php The defined functions are case sensitive, and a dynamic call to a static method will not be caught. string xdebug_start_trace( [ string trace_file [, integer options] ] )
Starts a new function trace
Start tracing function calls from this point to the file in the trace_file parameter. If no filename is given, then the trace file will be placed in the directory as configured by the xdebug.trace_output_dir setting. In case a file name is given as first parameter, the name is relative to the current working directory. This current working directory might be different than you expect it to be, so please use an absolute path in case you specify a file name. Use the PHP function getcwd() to figure out what the current working directory is. The name of the trace file is "{trace_file}.xt". If xdebug.auto_trace is enabled, then the format of the filename is "{filename}.xt" where the "{filename}" part depends on the xdebug.trace_output_name setting. The options parameter is a bitfield; currently there are three options:
The full path and filename to which Xdebug traces is returned from this function. This will be either the filename you pass in (potentially with ".xt" added), or the auto generated filename if no filename has been passed in. void xdebug_stop_code_coverage( [int cleanup=true] )
Stops code coverage
This function stops collecting information, the information in memory will be destroyed. If you pass "false" as argument, then the code coverage information will not be destroyed so that you can resume the gathering of information with the xdebug_start_code_coverage() function again. void xdebug_stop_error_collection()
Stops recording of all notices, warnings and errors as started by xdebug_start_error_collection()
Introduced in version 2.1
When this function is executed, error collection as started by xdebug_start_error_collection() is aborted. The errors stored in the collection buffer are not deleted and still available to be fetched through xdebug_get_collected_errors(). void xdebug_stop_function_monitor()
Stops monitoring functions
Introduced in version 2.4
This function stops the function monitor. In order to get the list of monitored functions, you need to use the xdebug_get_monitored_functions() function. string xdebug_stop_trace()
Stops the current function trace
Stop tracing function calls and closes the trace file. The function returns the filename of the file where the trace was written to. float xdebug_time_index()
Returns the current time index
Returns the current time index since the starting of the script in seconds. Example:
<?php Returns:
0.00038003921508789 0.76580691337585 void xdebug_var_dump( [mixed var [, ...]] )
Displays detailed information about a variable
This function displays structured information about one or more expressions that includes its type and value. Arrays are explored recursively with values. See the introduction of Variable Display Features on which php.ini settings affect this function. Example:
<?php Returns:
array 0 => array 0 => boolean true 1 => int 2 2 => float 3.14 more elements... 'object' => object(stdClass)[1] public 'foo' => string 'bar' (length=3) public 'file' => resource(3, stream) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This site and all of its contents are
Copyright © 2002-2017 by Derick Rethans.
All rights reserved. |