Changes

Jump to navigation Jump to search
1,177 bytes added ,  17:48, 9 October 2015
final
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 [http://derickrethans.nl/who.html Derick 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 ===
Here is what the wizard reported for me in my recent installation of xdebug
<blockquote>
'''Xdebug installed:''' 2.2.3 <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 might be a file in <code>/etc/php5/conf.d </code> In my case I actually did have <code>/etc/php5/conf.d/xdebug.ini</code>, but that file is superfluous because there are symbolic links for both '''apache2''' and '''cli''' that go to <code>/etc/php5/mods-available/xdebug.ini</code> (which helps PHP configuration files in there add to be the main phpsame for both runtimes.) Bottom line: run <code>locate xdebug.ini</code> to find out whether you have a duplicate/conflicting file; merge those files down to one; and make any overrides that you need from the default settings which xdebug will use if left unconfigured. SoThen <code>sudo service apache2 restart</code> and check your phpinfo() for correctness. The defaults are probably all good, but you end up editing many want to specify some of the following:<codesource lang="ini">sudo vim ;zend_extension=/usr/lib/php5/20090626+lfs/xdebug.sozend_extension=/usr/etclib/php5/conf20121212+lfs/xdebug.so ; enable debuggingxdebug.remote_enable = On; working from local machine; xdebug.remote_host = "127.0.0.1"; debugging from any machine on the local network, as well as through the routerxdebug.remote_host = "192.168.1.d0/24,127.0.0.1"; set which debug client protocol we wantxdebug.ini remote_handler = "dbgp"  </codesource>
Once you see xdebug in your phpinfo() output, you know it's enabled -- which means that you can already get xdebug functionality out of your PHP scripts (e.g. var_dump() is overridden). But how do you get debugging working so that you can use it with your IDE? That is covered in the '[http://www.xdebug.org/docs/remote remote]' section of the manual.
4,558

edits

Navigation menu