Debug remote PHP CLI scripts - eclipse

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

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.

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!

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

Related

eclipse rse tcl script remote debugging

I have dltk (tcl) and RSE installed in my eclipse.
I am able to debug local tcl scripts correctly. I am also able to edit remote tcl scripts using RSE.
Now I need to be able to debug a remote tcl script.
Is this possible and what are the steps needed to make it work?
Thanks

eclipse, remote systems explorer, custom commands

I'm on windows machine and using Eclipse to edit some files on UNIX remote. I use Remote System Explorer to browse files over SSH which works superb (comparing with N++ explorer it's a rocket). Now the UNIX files are under ClearCase versioning and I'd like to have some "right click" options in Eclipse's Remote System Explorer, associated with some unix commands (in my case will be ClearCase commands).
Should I start learning to make a simple plugin for this?
Note: There are some ClearCase readily available plugins but all of them requires ClearCase client to be installed on windows machine (which I did) but our admins doesn't allow the windows clients to access version database for security purposes :)
So now I use putty console (Eclipse console) to check in/out files then edit them with Eclipse. Any chance to do'it once like I explain above?
Thanks in advance,
No plugin possible, because ClearCase commands through an Eclipse plugin would be executed on your local machine, and not in the ssh session.
Those cleartool commands (checkout/checkin) must be executed where the view is started (ie on the unix remote server, where the ssh session is)

How to do remote debugging in Eclipse CDT without running `gdbserver` manually on the target every time?

Before each debugging cycle I have to run gdbserver on remote target (Linux). So I was thinking to make script that would call python program that would connect over ssh and would run gdbserver.
I cant find any options to run command before debug and I also try to change .gdbinit file but I am unable tu run python script whit that. Since I am using crosscompiler I cant to get other gdb whit such support.
You don't need to run Python to invoke an external command from GDB. This (in .gdbinit) should work:
shell ssh remote-host gdbserver :12345 /path/to/binary/on/remote &
target remote remote-host:12345
If you do need more complicated ssh setup and need Python for that, you can certainly get it with
shell python your_script.py
If you can't get any external program called from your gdbinit, I see one way of doing it within Eclipse that might work (I didn't tested) but it is not really straightforward...
Create an External Tool configuration that launches your gdbserver program (Python or whatever command line script)
Create a C/C++ application launcher that launch your application to debug
Create a launch group that will call the two previously configured configurations.
Launch the group in debug mode
Eclipse 4.7.0 can connect to SSH and launch gdbserver automatically with the automatic launcher set when creating a new debug connection, without the need for any custom scripts.
I have explained the setup in great detail at: Remote debugging C++ applications with Eclipse CDT/RSE/RDT

How to edit java files in remote machine using eclipse

my project source code is in unix, we are using CM synergy source control for code checkin/chech out files. we update the files using vi editor. Pls help in how to set up eclipse in windows system and then connect to the code server and edit the files.
You could install the Remote System Explorer framework, that allows opening files from a remote server, and also gives shell access to the remote server. For anything more specific, I'm not sure whether a free solution exists.
I experienced some problems accessing remote file systems with the Remote System Explorer Plugin, the FTP session was closed unexpectedly. I recommend for linking in your local projects remote sites Aptana Eclipse Plugin.

Eclipse CDT setup for remote build

Is there a better way to setup Eclipse CDT for local editing and remote building?
I am working on a C++ project that uses GNU make in Linux. The code is under CVS on a Linux server.
When I'm in the lab, I use Eclipse CDT on a Linux-x64 PC. The project is built on a Linux-x86 PC. All the computers in the lab (including the CVS server) have NFS mounts.
When I'm at home, I use Eclipse CDT on a Windows 7 PC. The Windows PC connects to the Linux CVS server via SSH tunnel. To edit source, I rsync the C++ project under the Linux Eclipse workspace back to my Windows Eclipse workspace. (I can also do a remote CVS checkout on the Windows PC.) To build from home, I use a custom build command that
SSH's to the Linux-x86 PC,
rsync's the C++ project from my Windows Eclipse workspace to my Linux Eclipse workspace,
and then runs make on the Liunx-x86 PC, specifying the correct path for the Makefile.
In order to go back and forth between lab and home without committing my changes to CVS every time, I use rsync. When I transition from lab to home, I rsync sources to my Windows Eclipse workspace. When I build from home, the sources get rsync'd back to the Linux Eclipse workspace.
Is there a better, less wonky way to do this?
(I'm NOT interested in remote debugging.)
Netbeans has good support for this. I've tried to get it working in Eclipse, but Netbeans was much easier with built in support.
One solution is to use Eclipse RSE (Remote System Explorer). It allows to "mount" a remote subfolder directly into the workspace (via FTP or SSH). CDT has some issues with the virtual file system used by RSE, but it ... well, more or less works.
There's some discussion on that on my question:
Work on a remote project with Eclipse via SSH
I need to do similar things, and I took a look at Synchronized Projects:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.ptp.doc.user%2Fhtml%2FlocalVsRemote.html
Synchronized projects support multiple build configurations, so the build can happen either locally or on one or more remote systems. The user can select which system will be used to build the project. A launch configuration can then be created to to run the application on the target machine.
To build on remote machine, follow Working with a Synchronized Project: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.ptp.doc.user%2Fhtml%2Fsync.html
How about using vnc and remotely logging in, using eclipse ON your unix box in the lab?
The only thing to go across the link is your editing, and vnc is pretty efficient about that.
This post seems quite old. But in case this might help somebody, I'd like to post a solution that works both on Linux and windows machines, which is really easy.
Now there is an Eclipse parallel version and you can just install that and change few lines in your remote machine's bash_profile to load few git functions. I'm even connecting from behind a gateway which is a little tricky. It is easier without. See this link:
http://umayanganie.blogspot.com/2017/05/build-debug-cc-projects-via-remote.html