Jump to: navigation, search

Debugging using XDebug

Revision as of 16:08, 30 September 2012 by Robert.dubture.com (Talk | contribs) (New page: = Debugging using XDebug<br> = XDebug is an opensource Debugger and Profiler for PHP. PDT has built in support for Xdebug, which allows you to step-debug through your PHP files.<br> <br>...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Debugging using XDebug

XDebug is an opensource Debugger and Profiler for PHP. PDT has built in support for Xdebug, which allows you to step-debug through your PHP files.


Setup


Installation

The first step is to install XDebug and verify that XDebug is running. See the Installation section of the XDebug manual for how to obtain the extension.


Configuration

The most importand setting for xdebug to work with PDT is xdebug.remote_enable = 1. Typically you set this value in your php.ini.


Usage


The following examples assume you're debugging on a local mashine, not a remote server.


PDT provides a preference dialog to configure different PHP servers. Each server has has a Base URL and a Local Web Root property.

When you start a debug session, the Base URL is used in conjunction with the script to debug to determine the absolute URL to open. For example, when you debug

the script index.php in the root of your Project with the default PHP Server, PDT will launch a debug session in a browser with the URL http://localhost/index.php.

If the Local Web Root property of a server is set, you can choose the Server as the base-directory in the New PHP Project dialog


Typically you will set the Local Web Root of the default PHP server (http://localhost) to the DocumentRoot of your local Web server (e.g. apache).

The default PHP server is http://localhost and has no Local Web Root set. So the first thing to do is to open the PHP Servers preference page, and set the Local Web Root to the DocumentRoot

of your webserver (e.g. /var/www/htdocs).localhost


When creating a new PHP project, you will now see a 3rd option named Create project on local server. The new project will be created in a subfolder of the Local Web Root of the selected server, not

in the default workspace path.


Now let's create a new empty PHP project named "MyProject" in the default PHP server and a simple index.php in the root of the project.