Monthly Archives: May 2012

PHP Remote Debugging on Zend Server for IBM i using xdebug and Netbeans

This is a guide on how to setup xdebug on Zend Server for IBM i.  The reason I did this was because the Zend Debugger doesn’t work with Netbeans, but it does work with the Zend Studio (which I don’t like using because its an Ecplise based IDE).

Step 1  Get and put it on the AS400 IFS

You can either compile your own by downloading the source from or you can just download this file.   Once you have the .so file you upload it to the Zend Server IFS directory for php extensions: /usr/local/zendsvr/lib/php_extensions

Step 2 – Setup php.ini file

PHP.ini location: /usr/local/zendsvr/etc/php.ini

Disable Zend Debugger and Zend Optimizer

You’ll have to turn off Zend Debugger and Zend Optimizer as these files will interfere with xdebug.  To turn off this go to /usr/local/zendsvr/etc/conf.d/debugger.ini and comment out ; zend_extension_manager.dir.debugger=/usr/local/zendsvr/lib/debugger with  a semi colon at the beggining of the line.  And comment out optimizerplus.ini in the same directory  ;zend_extension_manager.dir.optimizerplus=/usr/local/zendsvr/lib/optimizerplus You’ll also have to set php.ini to output_buffering = Off.  At the end of the php.ini file add the following lines: ; Xdebug Configuration [xdebug] zend_extension=/usr/local/zendsvr/lib/php_extensions/ xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req ;remote_host limits connection to the 1 ip address specified.  To find your ip on windows run ipconfig /all ;xdebug.remote_host=<client’s ip address> ; remote_connect_back allows for multiple connections from different IPs.  This is great for situations in which multiple developers will be developing on the same instance. xdebug.remote_connect_back=on xdebug.remote_port=9000

Step 3 – Restart Apache

On the i5/as400/iseries type: Go ZENDSVR/ZSMENU Option 5 – Service Management menu Option 6 – Stop Apache server instances Option 5 – Start Apache server instances

Step 4 – Setup xdebug client in Netbeans

Right click a project and go to project properties.  Set the Web Root to the local files that map to your Web Root on the i5 (htdocs/{myapps}).   In the run configuration set up the Project URL and the index file to point to your starting index.php file.  On the toolbar menu click Tools->Options ->PHP tab-> Debugging sub tab.  At this location you can set the debugger port, session ID, if it should stop at the first line of a file, what URLs were requested and to show the debugger console.

Step 5 – Launch Debugger

Hopefully if everything was setup right you’ll be able to start the debugger and Netbeans will open your website up in a browser and then connect to xdebug on the server.  The way it works is the client sends the request on port 80 and then the server and the client communicate over port 9000 or the port you selected.  You’ll get all the Variables, Call stack and be able to step through the PHP code and set up Break points through out the file. If your having troubles getting this working let me know.  Running phpinfo() will also give you an idea if you’ve correctly installed xdebug.

Misc. Tips

1. You may have to move the CW wrapper for the old i5 toolkit into your project file.  You can find those files in the /usr/local/zendsvr/share/ToolkitAPI folder on the IFS. 2. You can use xdebug’s wizard that uses your phpinfo and helps you detect and install xdebug – 3. If your looking to compile php on the iseries this site might help – 4. Netbeans wiki on how to configure xdebug  –