Remotely Debugging a PHP Script

This procedure describes how to debug files in your workspace remotely using your server's Zend Debugger. Use this function if you want to test the execution of the file in 'real time' on the production server. This is especially relevant if your server has loaded extensions.

Note:

Your server must be running the Zend Debugger or Xdebug in order for remote debugging and profiling capabilities to function.
The Zend Debugger comes bundled with Zend Studio and Zend Server. For instructions on installing and configuring Xdebug, see Installing Xdebug and Configuring Xdebug.

 

 

Instructions on how to complete a procedure

To remotely debug a PHP Script:

  1. Set breakpoints at the relevant places in the file that you would like to debug.

  2. Save the file.

  3. Click the arrow next to the debug button on the toolbar and select Debug Configurations... -or- select Run | Debug Configurations....
    A Debug dialog will open.

  4. Double-click the PHP Script option to create a new debug configuration.

New Debug Configuration

  1. Enter a name for the new configuration.

  2. Select the PHP Web Server option under the Debugger Location category.

  3. Select your server from the list.
    If you have not yet configured your server, click the underlined 'PHP Servers' shortcut. The Servers preferences page will open. Configure your server by following the instructions on 'adding a new server' under the PHP Servers Preferences page.
    For more information on configuring the communication between Zend Studio and your remote server, see Setting Up Remote Debugging.

  4. Under the PHP File category, click Browse and select your file.

  5. Marking the Breakpoint checkbox will result in the debugging process pausing at the first line of code.

  6. If necessary, you can add arguments in the PHP Script Arguments tab to simulate command line inputs.

  7. Click Apply and then Debug.

  8. Click Yes if asked whether to open the PHP Debug Perspective.

A number of views will open with relevant debug information.

See the "Running and Analyzing Debugger results" topic for more information on the outcome of a debugging process.

Note:

If the remote debugging session is unsuccessful, check that your server's root directory contains a Dummy File. This file should match the name of the Dummy File as defined in the Advanced Options section of the PHP Debug preferences page (accessible from Window | Preferences | PHP | Debug). By default, the file will be called "dummy.php".

Note:

If the file contains 'include' or 'require' calls to files which are not contained within the project, you must add them to the project's Include Path in order to simulate your production environment.
In addition, if a file defined with an absolute path to a server location (See 'Include Paths' for more on absolute file locations) is called, a Path Mapping dialog will appear. See Path Mapping for more information.