Automatic upload - Eclipse - FTP server

Eclipse is an IDE for implementation of applications in different programming languages. During the programing of an PHP web application it must be first deployed to the server in order to run it. It is possible to configure Eclipse to run a PHP program on local server, but sometimes it is necessary to implement the program locally and run it on a remote web server (because of the tweaking of the application or other reasons). We want to make the process of uploading of the PHP files to the appropriate folder on the remote FTP server automatic. The particular file should be uploaded after each save on the local disk.
1 answer

Automatic upload using Aptana plugin for Eclipse

Aptana plug-in for Eclipse adds a lot of functionality for web developers inclusive of the FTP connection possibility. It also supports scripting ('Monkey Scripts'), which will be used in this solution:

  1. Start Eclipse
  2. Click on 'Help>Install New Software'
  3. Into 'Work with:' type http://download.aptana.com/tools/studio/plugin/install/studio
  4. Install the Aptana plug-in
  5. In the root folder of the active PHP project create folder 'scripts'
  6. In scripts folder create file 'upload.js' with this content:
    /*
    * Listener: commandService().addExecutionListener(this);
    * Menu: Synchronize > Upload Current File On Save
    * DOM: http://localhost/com.aptana.ide.syncing.doms
    * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
    */

    /**
    * Returns a reference to the workspace command service
    */
    function main() {}
    function commandService()
    {
    var commandServiceClass = Packages.org.eclipse.ui.commands.ICommandService;

    // same as doing ICommandService.class
    var commandService = Packages.org.eclipse.ui.PlatformUI.getWorkbench().getAdapter(commandServiceClass);
    return commandService;
    }

    /**
    * Called before any/every command is executed, so we must filter on command ID
    */
    function preExecute(commandId, event) {}
    /* Add in all methods required by the interface, even if they are unused */
    function postExecuteSuccess(commandId, returnValue)
    {
    // if we see a save command
    if (commandId == "org.eclipse.ui.file.save")
    {
    sync.uploadCurrentEditor();
    }
    }
    function notHandled(commandId, exception) {}
    function postExecuteFailure(commandId, exception) {}

  7. Restart Eclipse
  8. Set up the FTP connection
  9. Click on 'Scripts>Synchronize>Upload Current File on Save'

Now Eclipse will automatically upload every file after it's saved.

Taggings: