Anash's Knowledge Base

Navigation

Shindig on PHP - Setting Up a Debug Environment (Take 2)

Overview

 

Shindig is a new project in the Apache Software Foundation incubator and is an open source implementation of the OpenSocial specification and gadgets specification. Details of Shindig can be found at http://incubator.apache.org/shindig/

 

Shindig is currently available in Java and PHP. The following article explains how to setup a debug environment for the PHP version of Shindig on your windows machine.

Setting up a debug environment

 

As one starts serious development with shindig, a development environment becomes indispensable. In my previous articIe, I wrote about using PHPEd as an IDE for debugging Shindig PHP codebase. However,PhpEd is a commercial IDE. For those who want to use an open-source alternative, I have listed how to setup debugging using  xdebugclient, an open source project available at http://code.google.com/p/xdebugclient/.

 

Setting up remote debugging

 

First, we need to setup remote debugging on Apache. To enable this, one has to do the following steps:

 
 
  1. Download dbg-wizard.php from http://www.nusphere.com/products/dbg_wizard_download.htm. This page will make the configuration process easy.
  2. Copy dbg-wizard.php to your htdocs/shindig/php folder.
  3. Modify the contents of your .htaccess file at htdocs/shindig/php as follows 

<IfModule mod_rewrite.c>

      RewriteEngine On

      RewriteCond %{REQUEST_FILENAME} !-f

      RewriteCond %{REQUEST_FILENAME} !-d

      RewriteRule (.*) index.php [L]

</IfModule>
 
    4.   Open a web browser and navigate to http://localhost/shindig/php/dbg-wizard.php. If everything goes well, you should see a page like this:
 
Towards the end of this page, you should find the configuration instructions. But for ease of discussion, I will list them below:
  • Enable PHP Debugger on our installation. To do this, go to C:\Program Files\nusphere\phped\debugger\server\Windows\x86. Copy the file php_dbg.dll-5.2.x to C:\Program Files\xampp\php\ext. 
  • Now, open the file C:\Program Files\xampp\apache\bin\php.ini in Notepad. Look for the following lines:
zend_extension_ts = "C:\Program Files\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"
 
Comment this line by putting a ; before the line.
 
  • Add the following line just above the line we commented:
zend_extension_ts=C:\Program Files\xampp\php\ext\php_dbg.dll-5.2.x
 
  • Add the following lines at the end of php.ini.
[debugger]
debugger.hosts_allow= 127.0.0.1 localhost
debugger.hosts_deny=ALL
debugger.ports=7869, 10000/16
 
  • Now save and close php.ini. Restart Apache.
  • Now navigate to your phpinfo() page on http://localhost. If things went fine, you should see a page as follows:
 
Note that the Zend Engine 2 box says, “Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with DBG v3.2.14, (C) 2000,2008, by Dmitri Dmitrienko”, which tells us that DBG has been activated in PHP. 

Configure XDebug Client for debugging

 
Start Xdebug client application. Now start the debug listener from the Debug Menu.


Now open a browser and navigate to the URL you want to debug. Remember to add XDEBUG_SESSION_START=1 to the end of the url.
For example, http://localhost:8000/shindig/php/social/rest/people/john.doe/@self?st=a:a:a:a:a:a&XDEBUG_SESSION_START=2 Will start the debugging of Shindig PHP's REST API. The following screen shows the project being debugged.