Debugging PHP
Installing PHPPHP debugging in Komodo requires PHP version 4.3.1 or greater (including PHP 5). Download PHP from http://www.php.net/downloads.php. To debug PHP scripts in a web environment, be sure PHP is operating correctly with your web server before configuring the debugger extension. Consult the PHP documentation for details on configuring PHP with various web servers. WindowsIf you are unfamiliar with the installation of PHP, we recommend using the Windows InstallShield package. To install the PHP executable or SAPI module manually, see the PHP website. Be sure that the PHP directory is included in your system's PATH. LinuxYour Linux system may already have PHP installed. Login and type 'php -v' to determine the version of your current PHP interpreter. If it is earlier than version 4.3.1 you must upgrade. PHP must also support loading dynamic extensions (the default for PHP under Linux). If it does not, reinstall PHP as per the instructions on the PHP website.
When installing PHP to a non-default directory, you must add the
following argument to the --with-config-file-path=/path/to/php.ini ...where /path/to/php.ini is the full path to the directory where the php.ini file is located. Refer to the PHP website for further information on installing PHP.
Local PHP DebuggingIn local debugging mode, Komodo executes PHP directly. While this is convenient for quickly debugging a PHP script, if your script depends on the availability of a web server, use Remote PHP Debugging even if the script is running on the same machine as Komodo. This makes it possible to test the script in its true environment. When debugging locally, certain environment variables are not available, such as those provided by the CGI environment. However, it is possible to simulate a CGI environment by specifying CGI environment variables and CGI input in the Debugging Options dialog box. It is is not necessary to install a web server to use Komodo's local debugging features. Once you have configured PHP to use the debugger extension as described below, you can debug your scripts by opening a PHP file and using Komodo Debugger Functions. If you receive an error message when attempting to debug a PHP script, check the PHP troubleshooting section of the Komodo FAQ. Configuring Local PHP DebuggingBefore debugging PHP scripts in Komodo, PHP must be configured to use the Xdebug extension (php_xdebug.dll or xdebug.so). Komodo's PHP Configuration Wizard simplifies the process of selecting a PHP executable to use for local debugging. It copies the php.ini file to a new directory, modifies it for debugging, then copies the Xdebug extension to the directory defined in the .ini file. The PHP Configuration Wizard should only be used to configure local debugging. To debug PHP remotely, see Configuring Remote PHP Debugging.To start the wizard:
The wizard will guide you through the steps necessary to configure the debugging extension.
Starting and Stopping a PHP Local Debugging SessionTo step through the script, from Debug menu, select Step In or press 'F11'. To run the script to the first breakpoint, from the Debug menu, select Go/Continue or press 'F5'. To stop the debugger, from the Debug menu, select Stop, or press 'Shift+F5'. See Komodo Debugger Functions for full instructions on using Komodo's debugging functionality.
Remote PHP DebuggingRemote PHP debugging encompases all types of PHP debugging not initiated from within Komodo, including debugging PHP scripts running under a local web server. When a PHP script is run through a web browser, the web server uses the PHP interpreter to execute the script. If PHP is configured for remote debugging, the server contacts Komodo to start a debugging session. Komodo controls the debugging (e.g. stepping and breakpoints) once the session starts. CGI variables are available, as are all other variables that are available when running PHP under a web server. Though remote PHP debugging allows PHP scripts to be run in their true environment, it may be slower than local PHP debugging. Configuring Remote PHP DebuggingRemote debugging of PHP in Komodo is set up differently depending on how many people will be debugging scripts on the same web server: Single User Remote PHP Debugging: In single user remote debugging, PHP is configured to always look for a specific instance of Komodo on a specific machine. This configuration requires no changes to the PHP script. Your web server and your instance of Komodo can be on one machine or two machines Multi-User Remote PHP Debugging: When multiple users need to debug PHP scripts on a single web server, use the DBGP Proxy with the remote PHP debugging instructions below. While it is possible to configure Apache with Virtual Hosting, it is easier to configure multi-user remote PHP debugging with the proxy. Remote PHP debugging must be configured manually. The following procedure assumes that you have already installed PHP. Step 1 - Copy the Debugging Extension to the Web ServerBefore debugging PHP scripts in Komodo, PHP must be configured to use the Xdebug extension (php_xdebug.dll or xdebug.so). Manually copy If you are installing PHP for the first time, the Windows
Linux
Step 2 - Edit the Web Server's PHP ConfigurationWindows Open the php.ini configuration file on the web server. In the
" ; xdebug config for Windows zend_extension_ts=c:\path\to\php_xdebug.dll xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_port=9000 xdebug.idekey=<idekey> Note: The php.ini configuration file should be in
your operating system directory (e.g. C:\WINDOWS or C:\WINNT), or in the same
directory as Linux Open the php.ini configuration file on the web server. In the
" ; xdebug config for Linux zend_extension=/path/to/xdebug.so xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_port=9000 xdebug.idekey=<idekey> Set the "remote_port" to the same value as the debugging listener port configured in Edit|Preferences|Debugger. Once the php.ini file is updated, verify that Xdebug is configured by running the following command: php -m Lists of all PHP and Zend modules are displayed. Make sure Xdebug appears in both lists. Note: Recent versions of PHP are set to buffer program
output by default. While debugging, it is useful to disable output buffering
so that results of Starting and Stopping a PHP Remote Debugging SessionOnce remote PHP debugging is configured, the PHP interpreter can contact Komodo and initiate a remote debugging session when a PHP script is executed on the web server. To debug a PHP script using a web browser:
To debug a PHP script remotely from the command line:
To debug a PHP script remotely using the DBGP Proxy:
Output from the debug session appears in the Bottom Pane of the Komodo Workspace. Komodo does not support a console for remote debugging. The browser will not show the script output until debugging is complete. To stop the debugger:
See Komodo Debugger Functions for full instructions on using Komodo's debugging functionality. If you receive an error message while debugging a PHP script that is not caused by the errors in the script itself, check the PHP troubleshooting section of the Komodo FAQ.
Using xdebug_break()The <?php echo "<p>Breaks after this line.</p>"; xdebug_break(); echo "<p>Breaks before this line.<p>"; ?> This function breaks the code during a debugging session but will not
initiate a new session. Use
|