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

  • Download the debugger from Zends website.
wget http://www.hurdmanivr.com/download/ZendDebugger-5.2.12-linux-glibc23-i386.tar.gz
  • Extract the file.
tar -xzf ZendDebugger-5.2.12-linux-glibc23-i386.tar.gz
  • Find out which version of PHP you are running.
PHP -v.
  • Switch to the directory, which you just extracted, that matches the version of PHP you are running.
cd 5_2_x_comp
  • Find out where your PHP modules are.
grep extension_dir /etc/php.ini
  • Copy the appropriate ZendDebugger.so into your PHP modules path.
cp ZendDebugger.so /usr/lib/php/modules
  • Add the following lines to the php.ini file. The allow_hosts line should include a remote IP as well. Can be a comma separated list.
; Zend Debugger
zend_extension = "/usr/lib/php/modules/ZendDebugger.so"
zend_debugger.allow_hosts = "127.0.0.1"
zend_debugger.expose_remotely = always
  • Copy the dummy.php file into the root of your web server.
cp dummy.php /var/www/html/
  • Restart apache. The command below works for Redhat, Fedora Code, CentOS and other Redhat based distros.
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…

  • Select the drop-down next to the tunnel icon and select Servers.
  • Add a new tunnel to the Asterisk server machine.

Start the Zend Debugger

  • Select Run, Debug URL.
  • Enter the URL of your asterisk server. I use the IP of the machine and run apache on a non-standard port.
http://67.50.48.18:50180
  • Click the Debug button.

Launch Asterisk

  • Make sure that your debug_asterisk.sh script starts on the same port that Zend used in the previous step (hint: look at the query string in Zend).
  • Start asterisk with your debug_asterisk.sh script.

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.

comments powered by Disqus
remote_debug_phpagi_scripts.txt · Last modified: 2020/06/01 22:53 (external edit)