DEV Community

Anurag Rana
Anurag Rana

Posted on • Originally published at Medium on

Editing Remote PHP Project Using Netbeans

Consider this scenario. You wrote some piece of code and placed it on a remote server. Now you need to edit the source file. How you will do it?

Here is the first approach -

  • SSH into your server.

$ ssh username@ip-address

  • Navigate to the directory where your source file is placed

$ cd path-to-folder

  • Edit the code using vi/emac/nano editor. Save it. Exit.

$ vi file1.php

Second approach -

  • Copy the file from the remote server to your local machine.

$ scp username@ip-address:path-to-file

  • Edit the file using your favorite IDE/Editor. Save it.
  • Upload the file back to the remote server.

$ scp path-of-file-at-local-machine username@ip-address

The third approach (Recommended for Large projects) :

Open the Netbeans IDE. Click on ‘new project’

Select ‘PHP’ from the categories list.

Select the ‘PHP application from remote server’ in the Projects list. Click Next.

On the ‘Name and location’ screen, write project name and click next.

On the ‘Remote connection’ screen click on the ‘Manage’ button.

Enter the connection name and select the connection type as ‘SFTP’. Click ok.

A new screen will appear (see screenshot). Fill the details like IP address, Username, and password. Port should be 22.

In the ‘Initial Directory field’ type the absolute path of the directory where your code is residing on the remote server. It may be ‘/var/www’ or something like ‘/home/user/project’.

After all the details are filled, click on the ‘test connection’ button. If everything is good then the connection will be successful.

In Project URL type http://localhost

Make sure your upload directory is correct. This is where your code will be saved when you will press contr+s on your screen.

Click next.

Now on the confirmation screen, it will ask for the files to download from the remote server. Check all if you want to download all the files.

On clicking the finish button, it will download all the files from the remote server to the local server. It may take some time depending on the size of the project.

Right click on the project name in the left pane of IDE. Click on the properties menu entry. It will open the project properties window.

Click on the ‘Run Configuration’ entry.

In the main pane, see for text field ‘Upload Files’. ‘On Save’ should be there. This means every time you save the files in your IDE they are updated at the remote server.

Every time a new file is created or deleted from IDE, the same change is reflected at the remote server. You can upload or download file explicitly by right-clicking the source folder in the project and then select ‘upload’ or ‘download’ option.

Now you need not to login to remote server every-time you need to update the files.

More from the Author:

Discussion (0)