In aÂ previous post I covered how to set up PHP step debugging in Zend Studio. But if that doesn’t work there may be a firewall in between the server and the debugging client, or IDE, preventing the connection. Here is a possible way to get around that.
Note: Of course there is no way to avoid the firewall, but this post assumes a connection to the server using SSH is possible. What we’ll do is allowÂ communications from the server to the client usingÂ the Zend Studio default debugging port (10137) forwarded through an SSH tunnel which usesÂ port 22 by default. For this to work an SSH connection must be possible from the client to the server.
While it is possible to do this using command line from Linux or Mac, or using PuTTY on Windows, this example will use the built-in SSH capabilities of Zend Studio 13. For older versions of Zend Studio I recommend using command line or PuTTY linked above.
Assuming step debugging in Zend Studio was already set up as outlined in my previous post we will continue using that setup, but enhance it with an SSH tunnel.
In Zend Studio open the preferences. (Windows|Preferences) With the preferences open, expand the PHP node to get to Servers. Highlight the server configuration to work with, and click Edit.
When the Edit Server dialog opens select the SSH Tunneling tab. Check the box to Enable SSH Tunneling, and populate the desired Username and Password. If your server requires the use of an SSH Private Key in order to login, please supply that.
Now that the SSH connection is set up we need to add the Port Forwarding for the debugging port. Do this by clicking the Add button in the Port Forwarding section.
NOTE: The SSH command would look like this:
$ ssh -R 10137:127.0.0.1:10137 [email protected]: -p 22
Select ‘remote’ to specify which side of the tunnel will be sending communication on the forwarded port, enter the local address the remote side (server) will use and port number to send to. Then enter the port number on the receiving end (the client). Now click Finish to applyÂ the setup, and click finish to exit the preferences.
In the PHP Servers view (Windows|Show View|PHP Servers) right-clickÂ the server we just added SSH Tunneling support to and select Open SSH Tunnel. You should then see a brief dialog letting you know the connection was made.
WeÂ are ready to debug!
Since I was using Zend Server in this example I have Z-Ray available, and while on a page I wished to debug I could simply click on the debug icon and select any of the debugging options.
This will cause Zend Debugger to contact Zend Studio for debugging, which in turn will ask the user if they wish to open the debugging perspective.
IMPORTANT NOTE: Debugging over an SSH tunnel is not fast. Therefore you may notice a lag between initiating the debug session and your IDE reacting. After that things speed up, but the initial connection is slow on many networks.
If Yes is selected the IDE is now ready to perform any debugging the user desires.
This post is one in a series on debugging. For others click below: