Table of Contents

Remote Debug PHPAGI Scripts

You can debug PHPAGI scripts remotely using the debugger from Zend Studio for Eclipse.

Requirements

You'll need some stuff!

  1. Zend Debugger from www.zend.com.
  2. Apache running on the Asterisk server.

Installing the Debugger

wget http://www.hurdmanivr.com/download/ZendDebugger-5.2.12-linux-glibc23-i386.tar.gz
tar -xzf ZendDebugger-5.2.12-linux-glibc23-i386.tar.gz
PHP -v.
cd 5_2_x_comp
grep extension_dir /etc/php.ini
cp ZendDebugger.so /usr/lib/php/modules
; Zend Debugger
zend_extension = "/usr/lib/php/modules/ZendDebugger.so"
zend_debugger.allow_hosts = "127.0.0.1"
zend_debugger.expose_remotely = always
cp dummy.php /var/www/html/
service httpd restart

Create a Debug Script

You'll need to set some Zend debugging values and then start Asterisk in console mode. If Asterisk is already running, stop it first.

Create a debug_asterisk.sh file containing the following lines.

#!/bin/sh
export QUERY_STRING="start_debug=1&debug_host=localhost&no_remote=1&debug_port=40814&debug_stop=1&debug_session_id=1003"
asterisk -vvvvc

Note hat this uses localhost and the 40814 port. You will use localhost when using a tunnel. Also, the port will change, possibly with each connection. Look at the URL that Zend uses to get the correct port number.

Setup the Tunnel

On the client machine, which is running Zend Studio…

Start the Zend Debugger

http://67.50.48.18:50180

Launch Asterisk

That's it. It will probably be a little slow, but Zend should open the debug tools and allow you to step through your PHPAGI code line by line, set break points, etc.