Issue

Connecting to IBM i resources like the ibm_db2 extension and the XMLSERVICE Toolkit can require middleware you may not have available on your PC. You can connect Zend Studio to Zend Server on your IBM i to debug your scripts using the PHP engine running on the IBM i. This will allow you to use the ibm_db2 extension and XMLSERVICE Toolkit running directly on the IBM i, without needing any additional middleware.

Environment

Zend Studio 11 for Windows, running on Windows 7, and Zend Server for IBM i 7.0.0 were used in writing this article.  Other versions will be similar, but may vary in the locations of options and settings.

*Note:  Zend Studio is no longer supported as of version 13.6.1


Resolution

Basic Configuration

Note: This procedure requires the ip address for your PC.  There are
some notes for Windows users on how to find the ip address at the end
of this article.

Step 1: Before you can configure Studio to connect to your IBM i, you must first configure your IBM i to allow your PC to act as a debug host. In the Zend Server User Interface, go to the Configurations -> IDE Integration tab. Find the "IDE Client Filtering for Debugging" heading.  Add an allowed host by entering it in the "Allowed hosts:" form. 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 validated.  Click the Add button.  Restart PHP to complete the process.

Example - Allow any ip address starting with 192.168 to be a host:


Example - Allow a specific ip address to be used as a Host:

Step 2: Create a PHP Server Definition.

If you have not already done so, please start Zend Studio now.

- In Zend Studio, Go to Window ->Preferences -> PHP -> Servers

- Click New

- Select Remote Zend Server and click Next

- Enter a Server Name that will be meaningful to you.  It can be anything.  The System Name of the IBM i partition might be a good choice, or anything that is meaningful to you.

- Leave the Debugger set to Zend Debugger.

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

Note: If you have modified your Apache configuration to use a different port, use that port here.

- Leave the Document Root empty.

- Click Next

- You can optionally enter the Host and Key information for Zend Deployment.  You do not have to do this at this time.  Click Next.

- You can optionally set up a connection profile for a Remote Project.  You do not have to do this at this time.  Click Next.

- You can optionally set up SSH Tunneling.  You do not have to do this at this time.  Click Finish.

Step 3: Set your new server as the default for the workspace.

- You should still be in the Preferences dialogue.  If not, go to Window ->Preferences

- In the Preferences dialogue, go to PHP -> Debug

- Set the PHP Server to the one you just created.

- Make sure "Break at First Line" is checked.

- Click Apply

Step 4: Make sure your PC ip address is first on the list

- You should still be in the Preferences dialogue.  If not, go to Window ->Preferences

- In the Preferences dialogue, go to PHP -> Debug -> Installed Debuggers

- Highlight Zend Debugger on the list, and click Configure.

- In the Client Host/IP field, the first listed ip address may be 127.0.0.1.  You need to move your ip to be the first on the list.

Before:

After:

Note: This step may not be necessary with future versions of Zend Server.

- Click OK to save your change

- Click OK to exit the Preferences dialogue.

Step 5: Verify the debugger is working

- Open a script you would like to debug.  This script must exist on the server, even if you want to debug the local copy of the script stored on your PC.  For example, if you want to debug a script named hello.php, there should be a /www/zendsvr6/htdocs/hello.php file on the server.

- Right click inside the script in the editor.  Select Debug as -> PHP Web Application in the context menu that appears.

- If prompted, click Yes to Confirm Perspective Switch. (Click the "Remember my decision" 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.  Use F8 to allow the script to continue running.

Find your 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.

Note: You may also need to check your ip address every time you 
restart your PC, if your address is dynamically assigned. These notes
apply to Windows 7.

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

- Enter the command ipconfig.

- Look for any ip addresses labeled "IPv4 address".  Your ip address will be one of these.  If you are directly connected to the same network as your IBM i (for example, if you are working from inside the office), you may only have one of these.  If you are attached to your office network from another location, like your home or on the road, you need to know which of these is assigned by the VPN.  Your Network Administrator or IT department can help you with this determination.

- If you have multiple ip addresses, and cannot determine which is the right one to use, try them each.  Just keep repeating the Basic Configuration steps above, to configure and test each ip address.