Wikidata/Development/XDebug
xdebug is a php module that allows debugging of php code directly in the IDE. With the help of the xdebug module, you can debug web requests with break points, variable inspection, etc.
Installation Edit
Ubuntu Edit
Under Ubuntu, you can just install the xdebug package:
apt-get install php5-xdebug
Mac OS X Edit
(assuming that you have homebrew installed):
brew tap josegonzalez/homebrew-php # set up the centralized repository for PHP-related brews by josegonzalez brew install php53-xdebug
Windows Edit
TBD
Resources Edit
- http://xdebug.org/wizard.php xdebug setup wizard
PHP Configuration Edit
Fox your IDE to be able to talk to xdebug, you need to enable remote debugging. Put this into your configuration:
xdebug.remote_enable=1
This can be done in your php.ini or a related configuration file. On Ubuntu, the correct file would be:
/etc/php5/apache2/conf.d/xdebug.ini
Browser Setup Edit
In order to debug a web application with xdebug, you need to start a debug session somehow. The simplest way to do this is a bookmarklet in your browser.
Firefox Edit
To start an xdebug session for some site (typically localhost, but could be anything), create a bookmarklet with the following content:
javascript:(/**%20@version%200.5.1%20*/function()%20{document.cookie='XDEBUG_SESSION='+'PHPSTORM'+';path=/;';})()
You can also use the bookmarklet generator: http://www.jetbrains.com/phpstorm/marklets/
If you are using PHPStorm, you may also want to install the JetBrains Firefox extension to enable JavaScript debugging. Note however that this plugin actually listens on a TCP port - make sure it's not open to the outside...
Chrome Edit
TBD
IDE Setup Edit
Setup with PHPStorm Edit
- Set a Breakpoint
- Start listening on the debug interface (click the red phone/handset button; it should turn green).
- Use your browser to request a page
- If necessary, configure path mappings for your project (PHPStorm will ask you when you hit a breakpoint for the first time).
- You should now be able to step through the code line by line, inspect variables, etc.
- Very useful: detailed walk-through with screen shots
Setup with Eclipse Edit
TBD
Setup with NetBeans Edit
TBD