Debugging PHPKomodo IDE only
Installing PHPPHP debugging in Komodo will work with PHP 4.3.10 or later, with the exception of versions 5.0.0 through 5.0.2. If you are using PHP 5.0, you will need at least 5.0.3 or greater. Download PHP from http://www.php.net/downloads.php. Refer to the PHP website for detailed information on installing 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 (or 5.0.0 through 5.0.2) 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. Mac OS XAlthough both the Jaguar and Tiger releases of OS X include a version of PHP, it is recommended that you obtain a more recent version. Either build from source code, or download a PHP module for OS X's Apache web server from www.entropy.ch/software/macosx/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 DebuggingKomodo configures itself automatically for local PHP debugging by
launching the default PHP interpreter (i.e. the first in your
PHP Debugger Config WizardIf the automatic configuration of PHP debugging is not successful, try configuring PHP debugging manually using the PHP Configuration Wizard. To start the wizard:
The wizard will guide you through the steps necessary to configure the debugging extension.
The PHP Configuration Wizard is only used to configure local debugging. To debug PHP remotely on a web server, see Configuring Remote PHP Debugging. If the wizard does not successfully enable local PHP debugging, refer to Configuring Remote PHP Debugging for more information on manual configuration and Common Local PHP Debugging Problems for information on common problems. Starting and Stopping a PHP Local Debugging SessionTo step through the script, from Debug menu, select Step In. To run the script to the first breakpoint, from the Debug menu, select Go/Continue. To stop the debugger, from the Debug menu, select Stop. 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). Find the appropriate extension for the version of PHP you are running and manually copy it into a directory on the server that the PHP interpreter and web server can access. The Xdebug files can be found in the php sub-directory of the Komodo installation. For example: Windows
Linux
Mac OS X
In the downloadable packages, the extensions are found in version-specific subdirectories of the unpacked archive. We recommend installing Xdebug in the existing PHP extensions directory on
the web server (specified by the 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_host=127.0.0.1 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 and Mac OS X Open the php.ini configuration file on the web server. In the
" ; xdebug config for Linux and Mac OS X zend_extension=/path/to/xdebug.so xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.idekey=<idekey> Set 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 initiate remote debugging from a web browser:
It is also possible to call <input type="hidden" name="XDEBUG_SESSION_START" value="jdoe" /> To initiate remote debugging from the command line:
To initiate remote debugging 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: On the Debug menu, select Stop or
pass the 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 Xdebug LoggingTo log xdebug sessions on the server, add the following line to the xdebug config section of the php.ini configuration file: xdebug.remote_log=/tmp/xdebug.log ...or add export XDEBUG_CONFIG="remote_port=9000 remote_enable=1 remote_log=/tmp/xdebug.org" You can replace " Common PHP Debugging ProblemsDebugging PHP on OS XThe version of PHP supplied with Mac OS X is not complied with loadable extension support, so it is not compatible with Komodo's debugger (Xdebug). For PHP debugging on OS X, either build PHP from source with loadable extension support or use binaries from http://www.entropy.ch/software/macosx/php/. The 4.3.11 or 5.0.4 for Apache 1 packages have been found to work well with Komodo PHP debugging. Debugging PHP on 64-bit LinuxThe version of Zend Optimizer and Zend Studio DebuggerXdebug is incompatible with the Zend Optimizer and Zend Studio Debugger extensions. If these extensions are enabled in php.ini, they will not be imported into the copy created by Komodo for debugging. When configuring Remote PHP Debugging, these extensions should be manually commented out in php.ini. |