Today’s session is given by derick rethans, the author of xdebug so he might know what he’s talking about.
Xdebug provides protections against things like stack overflow in PHP and infinite recursion. You can set this by setting the nesting level. It also provides a pretty formatted errors but not only is it pretty but it provides more information such as memory usage, time, function name and location on items in the call stack. It can also collect parameter information which shows the type with options to display the variable name (if possible) or values. It opts to minimal information to prevent crashing html displays with the browsers.
Another hot option is the ability to link to the files. The var_dump is overloaded to create a pretty, color-coded output. You can turn this off by setting the overload vardump option to 0.
You have to be careful with this because it can cause you to run out of disk space. What you will see is trace start, memory usage, nesting level. Green lines will show return value. One useful case is for realpath() to determine if the issue is the file doesn’t exist. It can show if you change the property of an element as well as modified variables. The trace filename output can be specified which allows you to create files for specific URLs or whatever you require. There is a script in the contributions directory that can help in xdebug output analysis.
You can trace select parts of the application with the xdebug_start_trace() and xdebug_stop_trace() methods.
PHP’s @ (shutup) operator hides warnings and errors. Setting xdebug.scream=1 makes PHP ignore @.
Xdebug collects all headers being set, implicitly and explicitly. This is awesome for testing and unit-tests. The function is called xdebug_get_headers().
If you use xdebug_start_code_coverage(), it will only monitor files parsed after the call. There is a tool called ‘phpcov’ that will render the output in a better format. Since the tool was written by @s_bergmann, the views look similar to phpunit coverage view.
The profiler looks pretty hot, didn’t catch the name of it but it gives a visual representation of the program execution (I think…I’m not exactly sure what i’m looking at other than it deals with profiling).
DBGp = common debugging protocol.
Activating the remote debugger
You enable the remote ability, need to set the host and port. On the shell, you’ll need to export a parameter or set a unique session in your browser. Firefox and Chrome have plugins. easy Xdebug is for firefox and Xdebug Helper is available for Chrome.
Looking for something?
Use the form below to search the site:
Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!