This setup allows you to step through php code, including looking at variable values, that’s running on a remote server….
- Downloaded and installed JDK (1.6.25)
- Downloaded and installed the Netbeans 7.0 PHP bundle
- Tried and failed to install xdebug on my 1and1 managed linux server
- Logged in using putty to ssh
- At the command line, ran “pecl xdebug”
- Discovered that I don’t have sufficient rights for PECL operation, and xdebug seems not to be already installed
- Installed xdebug on Titan (Windows XP Pro machine, with a WAMP5 server)
- Checked which version of xdebug would be right for my Titan WAMP5 installation, using xdebug wizard, at:
http://xdebug.org/find-binary.php - Pointed my browser at titan
- Clicked on phpinfo
- Scraped the webpage, put it into the wizard, which told me to use:
== php_xdebug-2.1.1-5.2-vc6.dll - Followed the wizard instructions:
- Checked which version of xdebug would be right for my Titan WAMP5 installation, using xdebug wizard, at:
i. Download php_xdebug-2.1.1-5.2-vc6.dll
ii. Move the downloaded file to c:\wamp\php\ext
iii. Edit C:\wamp\Apache2\bin\php.ini and add the line:
zend_extension_ts = c:\wamp\php\ext\php_xdebug-2.1.1-5.2-vc6.dll
iv. Enable xdebug in C:\wamp\Apache2\bin\php.ini
zend_extension_ts = “c:\wamp\php\ext\php_xdebug-2.1.1-5.2-vc6.dll”
[XDebug]
xdebug.remote_enable=1
xdebug.remote_host=”localhost”
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
v. These settings will enable xdebug, cause it to try to attach to a debug client on the local machine at port 9000 using the DBGp protocol
vi. Note that these settings do NOT need to be put into the website’s root directory, they affect xdebug for the entire Apache installation.
vii. Restart the Apache webserver
- Installed XDebugClient (xdc.exe) on Titan to test the xdebug installation there locally
- Downloaded 1.0 beta5 from http://code.google.com/p/xdebugclient/
- Placed it on Titan in Program Files, made a shortcut on taskbar. (no installer is provided, just put it somewhere and run it)
- It’s default is already port 9000.
- Created a simple dbgtest.php file in a xdebug-tests subdir of the www doc root of server (/www/xdebug-tests), containing the following code:
<?php
$a=1;
$b=2;
$c=$a+$b;
echo “a+b=$c”;
?>
- Started the XDebugClient, set it to Debug-Listen
- Pointed my browser at:
http://localhost/xdebug-tests/dbgtest.php?XDEBUG_SESSION_START=mysession.com
- The purpose of the parameter is to make xdebug issue a cookie with a longer browser session timeout.
- You can change that cookie’s expiration duration (default is 1 hr) using the php.ini setting:
xdebug.remote_cookie_expire_time = 3600
- see http://www.xdebug.org/docs/remote#browser_session for more info
- Observed the PHP source code appear in XDebugClient
- Observed the browser progress bar waiting without progress
- Did Debug-Run in the XDebugClient
- Observed the browser paint the result of the php code.
- Installed XDebugClient on a laptop (Mercury, a different machine than Titan, but on the same LAN segment)
- Changed Titan’s apache php.ini file to use the IP address of Mercury
xdebug.remote_host=”localhost”
- Repeated steps 7-9 above using a browser and XDebugClient running on Mercury
URL used was: http://titan/xdebug-tests/dbgtest.php?XDEBUG_SESSION_START=mysession.com
- Success
- Set up FileZilla FTP server on Titan, to support NetBeans ftp access to Titan.
- Perhaps another server would have been a better choice to support Internet-debugging, because there is no encrypted format compatible between Filezilla server and NetBeans
i. Filezilla does FTP and FTP over SSL/TLS, but not SFTP
ii. NetBeans does FTP and SFTP, but not FTP over SSL/TLS
- Set up a PHP project in NetBeans
- Set up a project for which the source files were already and only remote, in this case, so netbeans would pull my existing server php files to my dev laptop
- Set the source path to c:\websites\titan\www\xdebug-tests
- Set up the connection to the ftp server (note that Netbeans only does unencrypted ftp or sftp, doesn’t support ftp over ssl/tls, so doesn’t have an encypted solution for filezilla server which doesn’t do sftp)
- Set the destination directory to be /www/xdebug-tests
- Netbeans pulled my source file dbgtest.php to my local project directory on laptop
- I was able to debug that file, step through it, observe variable values, and finish (at which time the page appeared in a browser!), all without timing out!
- I created a bit more elaborate test file with a function call, that worked great, too:
- dbgtest2.php:
<?php
function foo($x,$y,$lbl){
$s=$x+$y;
echo $lbl.$s;
return true;
}
$a=1;
$b=2;
$c=$a+$b;
$r=foo($a,$b,”a+b=”);
if ($r) {
echo $r;
}
?>