1
votes

Here is my situation:

I am developing PHP CLI scripts on a distant server using Eclipse IDE with the RSE plugin (allows to edit files directly on the server).

Now I need to debug these scripts in a similar fashion than in Java (break points, show the variables content, ...).

I found something that could do the job: XDebug and PDT (Eclipse plugin). The problem is that when I try to launch the debug mode Eclipse says that there is no PHP debugger on the local machine. I guess it should be installed on the server machine.

I would like to know if it's possible to use PDT and XDebug to debug remote scripts and, if it's the case, how to configure them to do so. If not, I'd like to know if other solutions exist. It seems like XDebug uses TCP so it should be possible to debug remotely. I can change my IDE if necessary.

The server runs Ubuntu 10.04 with php5-cli and the dev machine with eclipse runs Win7 32bit.

Thanks

3
If you can't establish a direct connection, you might have to set up a ssh tunnel. (on Windows via putty afaik)mario
I just removed the unrelated issue.Marc Demierre
Thanks. It wouldn't get answered in this question anyway, and could sidetrack the main question.Piskvor left the building

3 Answers

4
votes

Yes this is possible, you need to enable xdebug in the remote server's PHP.ini file and make sure that the xdebug port (default 9000) is not blocked by any firewalls.

xdebug's page on setting up remote debugging.

2
votes

Here is the complete procedure for the people who have the same problem:

First, install RSE by following the instructions on this website: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.rse.doc.user/gettingstarted/g1installing.html

Follow the instructions on this HowTo to install XDebug on the server: http://ubuntuforums.org/showthread.php?t=525257

Install PDT on Eclipse and do the following changes: - under Windows/Preferences, go under PHP/Debug and change PHP Debugger to XDebug - under Windows/Preferences, go under PHP/Debug/Installed Debuggers and configure XDebug. Change the field "Accept remote session (JIT)" to "any".

Open the Remote System Explorer perspective, select your scripts directories and create a project from them (Right Click, Create Remote Project). It will now appear in the PHP perspective.

Let Eclipse run and go to the server (e.g. via SSH). Run the script you want to debug. A Window will then appear on Eclipse proposing you to choose with which "local" (remote via RSE in our case) file you want to link the running script to. Normally, the default script proposed should be the correct one, because it is the one running on the server.

You should now have visual debugging with Eclipse for your PHP-CLI scripts!

0
votes

Do you want to debug while being able to interact with the script on CLI or do you just want to start it and then step through the code? I guess your question is referring to the problem that you can't access the script directly through a URL. If that's your problem, then I guess the easiest solution would be to debug a usual PHP-web-site which requires your script. Then you can launch XDebug with that web-site initially and step into the script through the require/include-statement.

index.php:

<?php require_once("../../../../../dir1/[...]/cliscript.php");

Best regards

Raffael