PHPEclipse: A User Guide Chapter 8 Addendum

SFTP File Transfers

Versions of PHPEclipse prior to 1.1.8 included the Klomp SFTP plug-in. This plug-in mimicked the FTP plug-in, which allows files directly to be exported to an FTP server. Unfortunately, this plug-in is incompatible with the latest version of Eclipse, and in fact, will not work with any version prior to version 3.

Luckily for us, Chris A. Thomas has created the esftp plug-in to give Eclipse the ability to talk to SFTP servers. In this article, we will install esftp and walk through transfering a file.

Download and Install ESFTP

esftp is a Sourceforge project located at http://sourceforge.net/projects/esftp. Go to the downloads page. There are two things that you're going to have to install.

The first is esftp itself. Currently, it is at version 1.0.9. Download and unzip this. You will get a directory called plugins, and inside will be a directory named org.kmem.kosh.sftp_version_number. Like other plug-ins that we have installed so far, everything in this directory will be placed in the plugins folder. However, do not do this yet.

The plug-in in its current state lacks correct ssh libraries. Therefore, the second thing that is required is the libraries themselves. The libraries package is named esftp-lib. Its version will likely be the same or less than the current esftp version number. Currently, it is at 1.0.5. When you download and unzip this, you will get a directory named lib. Move this entire lib directory into the org.kmem.kosh.sftp_version_number directory.

Your org.kmem.kosh.sftp_version_number directory tree should look like this now:

Move org.kmem.kosh.sftp_version_number to the plugins directory under Eclipse. Restart Eclipse if necessary.

Why is esftp-lib packaged and installed seperately? This is because esftp-lib changes much less frequently than the rest of esftp. By not including esftp-lib with every release, it saves everyone the bandwidth costs.

Configuring ESFTP

Once installed, right click on a project in the Navigator View and select the project's properties. You will see an option for ESFTP in the right column now. Click on this option to activate the ESFTP preferences and server settings for this project.

ESFTP Preferences

The first tab, ESFTP Preferences, are the server connection settings for this project. Site Root is the absolute path to the site on the server. ESFTP assumes that everything underneath the Site Root mirrors everything under your project. The second section are the web site location settings for this project. If Recurse Directories is selected, when you upload a directory using ESFTP, ESFTP will drive deeper through all subdirectories. If Create Empty Directories is selected, any empty directories found in the project that is not on the server will be created on the server.

After the settings are entered, you should click on the Test Settings button to test the connection parameters and the site root. Click the OK button to dismiss this dialog box.

Using ESFTP

Using ESFTP is very easy. Select a file or directory in the project by clicking on it. You can also click on the entire project itself, or select multiple items by Alt/Command clicking on items. This will tell ESFTP what context to execute the file transfer. In other words, click on a single file to transfer the file, click on a directory to transfer only the directory, alt/command click on several files in a project to transfer those files, or click on a project to transfer the whole project. Now Right click on one of the selected items. You will see a new contextual menu item, "Esftp."

ESFTP Contextual Menu

There are three submenus. These three options are also available in the Toolbar and the ESftp menu. "Put File to Server and Save" will upload the selected item to the server and send a "Save" command to the file locally. "Put File to Server" will just transfer the file to the server. "Get File From Server" will navigate to where the file should be on the server and copy it to your project. Be careful because this will override your Workbench copy.

Select one and the file transfer will execute. A dialog box will appear. Afterwards, you can see the results of the file transfer in the Console view.

Console View Results