NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How can I use PHPEd to debug PHP CLI scripts on a remote ser


Joined: 16 Nov 2007
Posts: 8
Reply with quote
How can I use PHPEd to debug PHP CLI scripts on a remote server? The only place the scripts have what they need to run is on the server, and they need to have command line parameters passed to them.

- I have my router set up to route dbg to my development machine.
- I have no problem with remote debugging when the scripts are part of a web page where I can use post and get.
- I've run CLI scripts using ssh on port 22, and a break point that points to the development machine's IP.
- I've run CLI scripts connected on the dbg port, and set a break point with the development machine's IP and also tried localhost.


Last edited by JackT on Sun Jun 10, 2012 7:35 am; edited 1 time in total
View user's profileFind all posts by JackTSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
I don't myself debug PHP CLI scripts, but a few things that may assist.

1. Often CLI PHP uses a different config to the web PHP, so you might have to add the DBG debugger to a different php.ini and add suitable debugger config settings.

2. Whilst CLI PHP itself does not use a web server, as far as I am aware neither does the NuSphere DBG debugger except for detecting things like debug cookies. The debugger interfaces between PHP and the client PHP DBG Listener (which starts when PhpED starts). It communicates with the client using port 7869 (by default).

3. Double-check firewall settings where-ever PHP is running to ensure it allows port 7869 through.

4. You may need to use the DebugBreak() statement to invoke the debugger at a suitable point in your script. DebugBreak can be told how to communicate with the PhpED client. Once the debugger is invoked, breakpoints, etc. will start working.

5. You will find various information about DebugBreak in this forum but have a look at http://forum.nusphere.com/remote-debug-when-server-receives-a-request-t8269.html?highlight=debugbreak and http://forum.nusphere.com/how-to-use-dbgsessid-t8348.html?highlight=debugbreak
View user's profileFind all posts by plugnplaySend private message


Joined: 16 Nov 2007
Posts: 8
Reply with quote
This is not a shared hosting environment, it's a standard UNIX/FreeBSD install so there is only one php.ini. The setup wizard comes back all green, and as long as the script is being run by Apache, everything is fine, so there can't be any connection problems. The only time there is a problem is with CLI scripts. DebugBreak has the recommended public IP of the development machine, although if I put the CLI script in the web root on the same machine, debug works fine with it, and doesn't even need the break, since it will automatically stop on the first line of the script. Of course in the real world that won't work because CLI scripts need parameters.

I have it working. No amount of posts helped. It came from studying the parameters and figuring out how it all works.
View user's profileFind all posts by JackTSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Did you try the follwoing?
php myscript.php DBGSESSID=1@MyPhpedMachineIP:7869

To determine MyPhpedMachineIP, you can invoke phpinfo() through Apache's php and copy _SERVER['REMOTE_ADDR'] value.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
How can I use PHPEd to debug PHP CLI scripts on a remote ser
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic