Facebook

Editing remote PHP project using Netbeans


Consider this scenario. You wrote some piece of code and placed it on 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 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

Third approach (Recommended for Large projects) :

- Open the netbeans IDE.
- Click on 'new project'
- Select 'PHP' from categories list.
- Select the 'PHP application from remote server' in Projects list.  Click Next.


  

- On the 'Name and location' screen, write project name and click next.


- On the 'Remote connection' screen click on '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 directory where your code is residing on remote server. It may be '/var/www' or soemthing like '/home/user/project'.



- After all the details are filled, click on the 'test connection' button. If everything is good then 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 confirmation screen it will ask for the files to download from remote server. Check all if you want to download all the files.


- On clicking the finish button, it will download all the files from remote server to local server. It may take some time depending on the size of 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 new file is created or deleted from IDE, same change is reflected at remote server. You can upload or download file explicitly by right clicking the source folder in 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.


8 comments:

  1. Good & Innovative Collection Admin :) :)

    ReplyDelete
  2. Replies
    1. That is why blog name is "Newbie" :P

      Delete
    2. I wrote in context of "Newbie", means it's pretty basic even for Newbies :P

      Delete
    3. not that basic yar :) .

      Delete
  3. But the process is really slow..since I posted it, I have been trying download remote files to edit...its still downloading....after close to 2 hours!!!!

    ReplyDelete