Jump to content

Wikidata/Development/XDebug

From Meta, a Wikimedia project coordination wiki

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]

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.

Setup with Eclipse

[edit]

TBD

Setup with NetBeans

[edit]

TBD