Open main menu

Changes

1,266 bytes added ,  16:26, 9 October 2015
tmp save
Debugging a PHP application can involve quite a bit of machinery, and effort getting that machinery setup. But it's worth it because what alternative is there? <code>echo</code>? Come on!
 
Thanks to Derrik Rethans, xdebug can do a ton of cool things for you. For example, it overloads <code>[https://secure.php.net/var_dump var_dump()]</code> and gives '''you''' [http://www.xdebug.org/docs/display control over how you want deeply nested data structures to be displayed].
== First get Xdebug setup ==
=== Summary ===
<blockquote>'''Xdebug installed:''' 2.2.3<br />'''Server API:''' Apache 2.0 Handler<br />'''Windows:''' no<br />'''Zend Server:''' no<br />'''PHP Version:''' 5.5.9-1<br />'''Zend API nr:''' 220121212<br />'''PHP API nr:''' 20121212<br />'''Debug Build:''' no<br />'''Thread Safe Build:''' no<br />'''Configuration File Path:''' /etc/php5/apache2<br />'''Configuration File:''' /etc/php5/apache2/php.ini<br />'''Extensions directory:''' /usr/lib/php5/20121212+lfs</blockquote>Caveat: their script can't really tell where the xdebug configuration lives. In Ubuntu, there is a /etc/php5/conf.d and configuration files in there add to the main php.ini. So, you end up editing <code>sudo vim /etc/php5/conf.d/xdebug.ini </code>
Caveat: their script Once you see xdebug in your phpinfo() output, you know it's enabled -- which means that you can't really tell where the already get xdebug configuration livesfunctionality out of your PHP scripts (e.g. var_dump() is overridden). In Ubuntu, there But how do you get debugging working so that you can use it with your IDE? That is a /etc/php5/conf.d and configuration files covered in there add to the main php.ini. So, you end up editing <code>sudo vim /etc'[http:/php5/confwww.d/xdebug.ini <org/docs/code>remote remote]' section of the manual.
Following the sage advice of the [http://wiki.netbeans.org/HowToConfigureXDebug#General_Information Netbeans wiki], you want to get xdebug's '''debugclient''' working on localhost first, then add Netbeans.
 
xdebug provides several configuration parameters as well as functions that you can use in your debugging code. One important parameter is the <code>[http://www.xdebug.org/docs/stack_trace xdebug.file_link_format]</code> which determines the format of the links that are shown in stack traces. This allows for integration with your IDE so that, for example, Netbeans will find and open the file in your local sources.
 
[http://www.xdebug.org/docs/profiler Profiling] your PHP code is another feature enabled by xdebug.
4,558

edits