IBM i example: PHP Project from Remote Server
When the PHP Project with Remote Server Support is completed, you will be able to edit and debug scripts stored locally in a specified folder, and automatically or manually upload edited scripts to the application directory on the IBM i IFS.
The following instructions assume that an SSH connection has been successfully made to your IBM i machine. To learn more about setting up an SSH connection, please refer to the following Knowledge Base article: IBM i example: Configure an RSE Connection
You also need to be able to do Remote Debugging. The following Knowledge Base article can help you configure and test the Remote Debugging set up: IBM i example: Configure Remote Debugging
In this example, there is an existing directory hosting the scripts for your application on the IBM i IFS:
So, for example, if you had a script:
You would run the script in your browser at this address:
http://<your IBM i IP address>:10088/myapp/hello.php
1. Open Zend Studio.
2. Go to File | New | PHP Project from Remote Server.
This brings up the "New PHP project with remote server support" dialog, on the Remote Configuration tab.
3. In the 'Project Name' field, enter a project name. In this example we will call it "My Application".
4. In the 'Location' field , select a location for your project.
5. Adjacent to the 'Remote Connection' field, click the Manage button. If you created an SSH connection to your IBM i previously, you can select that connection from the list box, or click Add to add a new connection. Change the "Initial Directory" to the name of the directory on the IBM i that contains your project directory (do not include the project directory name itself, this is the path to the container). For our example, the "Initial Directory" will be:
6. Test the connection by clicking Test Connection.
If it does not work, you can refer to Zend Studio's online documentation to set up your SSH connection.
7. Once you have a successful connection test, click Finish.
This returns you to the "New PHP project with remote server support" dialog.
8. In the 'Project Directory' field enter the project directory.
In our example the Project Directory is 'myapp' .
You will notice as you type in the Project Directory that it is also appended to the Project URL, so that the Project URL looks like this:
http://<your IBM i IP address>/myapp
9. Add the port identifier ':10088' to the URL, so it looks like this:
http://<your IBM i IP address>:10088/myapp
10. Click Next.
This brings you to the File Download Confirmation dialog. You will see two list boxes, containing the directory structure and scripts found in your application folder on the IBM i. They will all be selected. This will cause all of this content to be copied to the project directory on your PC.
11. Click Next.
This brings you to the Libraries dialog. This dialog allows you the option to place some predefined libraries into your project. In this example, we do not need any of these libraries.
12. Click Finish.
This will create the project.
13. In the PHP Explorer view, click the arrow on the left of your project to expand the views. All of your scripts from the myapp folder, as well as any subfolders, will be there.
14. To confirm that the Base URL used by the debugger includes the port (In this example, we are using the default Zend Server port of 10088), right-click your application in the PHP Explorer view, and select Properties from the context-menu.
The project Properties dialog is displayed.
15. On the list on the left, select the "PHP Debug" page. On the right, near the bottom, find 'Auto-generated Base URL', and verify that it is in this format:
http://<your IBM i IP address>:10088/myapp
16. If the port is missing, look up the page at the "Default Settings", and make a note of the "Server:", but do not change it. If port is ok, skip tthe rest of the steps.
17. Click the PHP Servers link. This will take you to the preferences for PHP Servers. Find the server you noted previously, click to select it, then click Edit. On the "Edit Server" dialogue, find the "Base URL:" and add the port. Change it from http://<your IBM i IP address> to http://<your IBM i IP address>:10088.
18. Click OK to save the change.
19. Back on the PHP Servers Preferences, click OK.
20. Back on the PHP Debug properties for your project, click OK.
21. Return to the PHP Debug properties to verify that you now have the correct Auto-generated Base URL.
To debug a script remotely, right-click the script in the PHP Explorer, or right-click inside the script in the editor. Select Debug As | PHP Web Application. The "Launch URL" will show in a pop up window, and will be the URL for the script located on your server. However, the actual script being debugged is the one in your project, so you can test any changes that you have not uploaded to the server yet. Click OK to proceed with the Debug session.
When you edit the scripts from the project, you are editing the local copy on your PC. You can choose from three options to upload your scripts. You can upload the script whenever you save your changes, upload your script whenever you run it or debug it in Zend Studio, or you can choose to manually upload your scripts. The default setting is "On Save". To change this setting, right-click your application in the PHP Explorer pane, and choose Properties from the context menu. On the list on the left, find "Remote Server Support" and click it to select. On the right, find "Project Mode" and a drop down for "Upload Files". Choose the desired option from the list. Click OK to save the change.