IBM i example: Configure Remote Debugging

Symptoms

The internal Studio debugger does not support i5/OS functions.

Summary

The way to use Studio for i5/OS with your i5 is to use Remote Debugging. This will allow you to compose a script on your PC and run it in Studio using the php engine running on your i5. You will need to do this to access the i5 Toolkit Functions such as i5_connect(), as well as the ibm_db2 extensions, such as db2_connect().

Basic Configuration

Step 1: Before you can configure Studio to connect to your i5, you must first configure your i5 to allow your PC to act as a debug host. In the Zend Server Administrator, go to the Server Setup -> Debugger tab. Add an allowed host by entering it in the top line. Enter the ip address for your PC. You can enter all or part of the ip address, to represent a range of valid host addresses.  Use the dropdown to indicate how much of the ip address is checked.  Click the Add button.  Restart PHP to complete the process.

Open Zend Studio for Eclipse – i5 Version in the PHP Perspective, then proceed with the remaining steps.

Step 2: Create a PHP Server Definition.

- Go to Window >Preferences > PHP > PHP Servers

- Click New

- Enter a meaningful name for your PHP Server

Note: Use the correct port for your application
In the next step, we recommend to use port 10080, which is the default application port for Zend Server for IBM i version 6.  If your application is found on a different port, use that port.  For example, the default port for Zend Server for IBM i version 5 was 10080.

- Enter the URL for port 10080 on your i5. For example, if your i5 ip address was 192.168.23.175, you would enter http://192.168.23.175:10080

- Click Finish

- Click OK to close the Preferences Dialog

Step 3: Complete the Debug Dialog

- Go to Run > Debug Configurations…

- Highlight PHP Web Page

- Right click PHP Web Page and click the New button

- Enter a meaningful name

- Select the PHP Web Server button

- Select the PHP Server defined in Step 2

- Select a PHP File to Debug. Use the Browse button to find a file.  (Note:  a file with the same name must exist on the server, even if you are debugging the local copy of the script.)

- Click Apply

Step 4: Verify the debugger is working

- Click Debug

- If prompted, click Yes to Confirm Perspective Switch. (Click the "Remember my decision" box to bypass this dialog in the future.)

- If prompted, click OK to acknowledge the Old Zend Debugger Protocol ID message. (Click the "Don't show this message" box to bypass this dialog in the future.)

- Your PHP file should open in the Debug perspective, and break at the first line. You should be able to continue debugging from here.

Step 5: Specify the local ip address.

- This step may be required if your workstation is using multiple ip addresses. This can happen if you are using a VPN, or if you have both a wifi and wired connection, or if you have virtual addresses for VMWare virtual machines, or some other situations. This step is documented for Windows.

- Open a Windows Command Prompt (Start -> All Programs -> Accessories -> Command Prompt)

- Enter the command ipconfig.

- Find the ip address that is last on the list. (You may need to repeat this step using each ip address shown, until you find the right one to use.)

- In Zend Studio for Eclipse, go to Window > Preferences > PHP > Debug > Installed Debugger.

- In the list of Installed Debuggers, you will see one item, Zend Debugger. Double click it, or highlight it and click the Configure button.

- In the Client Host/IP box, there is a list of ip addresses, separated by a comma. Edit this list to show only the ip address noted from ipconfig and 127.0.0.1.

- Check your allowed hosts to verify that this is a valid ip address to use with the debugger. If not, please update the alllowed hosts and restart Apache.

- Retry Step 4. If it does not work, please try again using a different ip address from the ipconfig display.

- You may need to redo Step 5 when you restart Windows, if your assigned ip address is changed by the server.

Tunneling

If the debug will not work, please try Tunneling. To start, find the Tunneling icon on the toolbar. It is a tiny red square with pipes running into it from the left, right, and top.

Next to the Tunneling icon is a drop down arrow. Click it, and select Servers. The Server defined in step 2 above should appear on the list. Highlight your server, and click Edit.

On the Tunnel tab, select the Enable Tunneling check box. You may need to specify the Return Host, which would be the local ip address. (You can leave this blank for now, to experiment. Come back later to set it up if the Tunnel does not work.) See Step 5 for instructions to find your local ip address.

Click OK to save the changes to your Server. Click OK to close the PHP Servers Preferences.

Click the drop down arrow next to the Tunneling icon. Your server should now appear on the list above the Servers selection, because it is specified as a Tunneling server. Click your server to select it. If Tunneling is successful, the Tunneling icon will turn green.

To end Tunneling, just click on the Tunneling icon. It will turn red to indicate Tunneling is ended. Be sure Tunneling is enabled for your Tunneling Server when you use it to debug.

The information in this article applies to

Zend Studio 8 for i5/OS and Zend Server 6 for IBMi