Tuesday, May 8, 2012

how to setup PHP remote debug using komodo IDE & xdebug in Mac OS X


Step 1 - Copy the Debugging Extension to the Web Server

Before 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:
  • Filexdebug.so
  • Location<komodo-install-directory>/Contents/SharedSupport/lib/support/php/debugging/<PHP-version>/ 

zend_extension_ts or zend_extension
Should be set to the full path to the xdebug library on your system. Use zend_extension_ts ("thread safe") on Windows and zend_extension on other platforms.
xdebug.remote_enable
Enables remote debugging.
xdebug.remote_handler
Should be set to dbgp for use with Komodo.
xdebug.remote_mode
Set to req to have the script connect to Komodo when it starts. Set to jit to connect only on an error condition (see PHP Just-in-Time Debugging / Break on Exception).
xdebug.remote_host
Set to the hostname or IP address of the computer running Komodo or the DBGP Proxy. Use 'localhost' or '127.0.0.1' if Komodo and the web server are running on the same system.
xdebug.remote_port
Set to the same value as the debugging listener port configured in the Debugger Connection preferences (or the system assigned Host Port displayed under Debug|Listener Status)
xdebug.idekey (optional)
If you are using the DBGP Proxy, set this to the Proxy Key configured in the Debugger Connection preferences.



Starting and Stopping a PHP Remote Debugging Session

Once 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:

  1. Ensure PHP is installed and configured properly for your web server.
  2. Ensure Komodo and PHP are configured for remote debugging (as described in "Configuring Remote PHP Debugging").
  3. Click Debug | Listen for Debugger Connections.
  4. In your browser, enter the URL of the script you want to debug. Append ?XDEBUG_SESSION_START=1 to the end of the URL (an HTTP GET with a true boolean value). For example:
    http://example.org/sample.php?XDEBUG_SESSION_START=1
    
    If you are using the DBGP Proxy, the value for the GET method should match the Proxy Key value shown in Debug|Listener Status. For example:
    http://example.org/sample.php?XDEBUG_SESSION_START=jdoe 
    It is also possible to call XDEBUG_SESSION_START by adding it in an input element of an HTML form. For example:
    <input type="hidden" name="XDEBUG_SESSION_START" value="jdoe" />
    
    Note: This is only required for the first request. After that, Xdebug tracks the debugging session with a cookie. For more information on how this works, see www.xdebug.org/docs-debugger.php#browser_session
  5. A PHP debugging session starts in Komodo. On the Debug menu, click Step In or Go/Continue to run to the first breakpoint.



No comments:

Post a Comment