1

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
  • 1
    If you can't establish a direct connection, you might have to set up a ssh tunnel. (on Windows via putty afaik) Commented Feb 2, 2011 at 15:17
  • I just removed the unrelated issue. Commented Feb 2, 2011 at 15:19
  • Thanks. It wouldn't get answered in this question anyway, and could sidetrack the main question. Commented Feb 2, 2011 at 15:27

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi and thanks for the answer. I could already configure Xdebug and I tried to access it from the Windows machine. After that, I could use the windows client on the linked page to test. Then, I could access it with eclipse PDT. In fact it was just a configuration problem on the server side (I did in in apache's php.ini instead of cli php.ini).
2

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!

Comments

0

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

1 Comment

Well the script just needs to be lauched with some command line arguments and then I need to step in the script while it's running. The solution you propose would be kind of difficult because the script is not well done, not by me and not commented either, unfortunately ;(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.