Debug PHP with Xdebug

Debug PHP with Xdebug allows the programmer to analyze, evaluate and find errors in the code line by line. phpDesigner 7 supports debugging PHP with Xdebug.

Configuration

In order to use Xdebug you must have PHP installed local on your computer configured with the Xdebug extesion.

By default, phpDesigner 7 comes with a PHP package and Xdebug. If not, please follow these steps

  1. Download the latest PHP 5.x.x. package (not the installer) from http://www.php.net
  2. Download the Xdebug extension for the PHP version you have installed in the previous step from http://www.xdebug.com . For example if you have PHP 5.3.1 installed, you need Xdebug 5.3
  3. Place the Xdebug extension in the extension folder where you installed PHP, for example c:\…\PHP\ext
  4. In the folder where you installed PHP, open the file php.ini.
  5. Add a new section called [Xdebug] in the file php.ini:
[XDebug]
zend_extension="./ext/php_xdebug.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

Configure phpDesigner 7 to know where to find the PHP interpreter (php.exe, win-php.exe or php-cgi.exe).

  1. On the Tools menu, point to Preferences
  2. Select Debugger
  3. In the field 'PHP' type in the path for the PHP interpreter (.exe), or click the Browse button to locate the PHP interpreter

Sessions

Start a debug session from within the IDE or from the web browser and execute your script until the first breakpoint or error occurs.

In order to start a debug session the Xdebug server must be started. You can start, restart or stop the Xdebug server on the Debug menu, select Xdebug IDE server.

Run/Continue

On the Debug menu, select Debug or press F9. When a debug session has been paused you can continue the debug session by pressing F9.

Step into/over

This will start the debug session as in Run but will pause the execution at the first line of the script allowing you to step through the code.

  • On the Debug menu, select Step into or press F7.
  • On the Debug menu, select Step over or press F8.

Run to cursor

This will start the debug session as in Run but will pause the execution until the line at cursor is reached. If any breakpoints or errors occurs before the line at cursor is reached the execution might be paused.

  • On the Debug menu, select Run to cursor or press F4.

Run until return

This will start the debug session as in Run but will pause when pressing the return key. If any breakpoints or errors occurs before the line at cursor is reached the execution might be paused.

  • On the Debug menu, select Run to cursor or press Shift+F8.

Breakpoints

Use breakpoints to signal the debugger to temporarily suspend execution of your script at a certain point. Here you can examine your script for violations or bugs. Execution can be resumed at any time.

  • On the View menu, click Tool Panels and select Breakpoints

Insert/remove a breakpoint

  • On the Debug menu, click Toggle breakpoint or F5

Enable breakpoint

To enable a breakpoint, go to the breakpoint window and right-click on the row and select 'enable'.

Disable breakpoint

Disabling a breakpoint makes the breakpoint inactive without removing it. To disable a breakpoint, go to the breakpoint window and right-click on the row and select 'disable'.

Call stack

Trace the course of the executions in your script throughout the debugging session.

  • On the View menu, click Tool Panels and select Call stack

Variables

Display the value of all global and local variables throughout the debugging session.

  • On the View menu, click Tool Panels and select Variables

Watches

Monitor variables, objects, properties etc. throughout the debugging session. Monitored variables should start with a “$” (dollar sign).

  • On the View menu, click Tool Panels and select Watches.

Evaluation

Evaluate and test expressions in your script. Manipulate variables direct during a debugging session. Manipulated or injected variables will affect the value of the variable when the execution of the script continues.

Move the cursor upon variables to see their values.

  • On the View menu, click Tool Panels and select Evaluation.

Log

This are the messages Xdebug sends to phpDesigner 7.

  • On the View menu, click Tool Panels and select Log.