![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
XDEBUG EXTENSION FOR PHP | DOCUMENTATION When 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 whould 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_exception_trace
Type: integer, Default value: 0
When this setting is set to 1, Xdebug will show a stack trace whenever
an exception is raised - even if this exception is actually caught.
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:
<?phpReturns:
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:
<?phpReturns:
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)
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 ] )
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 was introduced in Xdebug 2.1. Example:
<?phpReturns:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This site and all of its contents are
Copyright © 2002-2013 by Derick Rethans.
All rights reserved. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||