I noticed a strange sync problem. I have my project setup as a remote project and everything works fine. I have it set to upload on save. However, if someone on my server is working on a file and saves it. I don't see this change in netbeans and I end up opening a older version of the file and overwriting my colleague's changes when I press save.
Is there a way to have netbeans check the remote server for the latest file before saving?
thanks
No, NetBeans can not check the remote file automatically. It's just not set up to do that. Even if it were, you would still run into problems where you would clobber your colleague's changes, or he would clobber yours.
What you have is a basic version control problem, which is best solved by implementing one of the several version control systems out there (e.g., CVS, Subversion, Git, Mercurial, etc.) and then "building" your website out to the server from version control. Short of that, an imperfect solution would be to partition the files such that you are forbidden to edit files assigned to your colleague, and vice-versa.
NetBeans can download the file for you, but only when you tell it to by right-clicking on the file and choosing the Download command. This downloads the file whether it has been updated by someone else or not.
Related
When my laptop got stuck I restarted the pc. Unfortunately, when I open the NetBeans after restart it erased the entire php file. I don't have a backup.
Please help me to recover. I can pay for the work.
Thanks
NetBeans has a local history feature - check if you have anything there. With some luck you will be able to restore last saved version of a file.
But you should learn something from this situation:
Always do a backup. You should have a backup of every file which has any value for you - it is only a matter of time when you lose something and backup may save your life then. Don't forget to test that your backup actually works.
Use some version control system for your code. With git you can easily create local repository with your project history.
In the past, with Eclipse and a PHP Server/system, I had it setup so that when I commited changes to the CVS repository, it also saved the actual php files on the server. I had this functionality on a another computer in the past (I can't check this computer). The files for the repository seemed to have been saved in a different folder. So the cvs is in a folder stucture like var/cvs and my system files/PHP files facing clients are in something like var/www/html/. How would one go about setting something like this up? I use sftp to change files right now with Filezilla. It was very convenient before being able to commit the changes and check the web to make sure that changes worked. Right now I have to commit the changes then save the file with ftp to see the changes. Would love to be able to get rid of the sftp with Filezilla step if at all possible...
It sounds to me that you are testing your latest changes on the live website, which is bad idea, because if you inadvertently edit some error in the files, your website may expose that to the public.
My current work-flow is as follows:
I use Netbeans on a local project, which is the SVN checkout too. On most projects I use the Netbeans option "Copy files from source folder to another location" to copy the edited files "on save" to the local test webserver directory. If the changes work on the local webserver, I'll commit them to the SVN repository and login to the live-webserver via SSH and checkout the latest revision from the SVN.
So in fact I have four copies of each file:
The working copy (a Netbeans project and SVN checkout)
/home/feeela/projects/xyz/ (editing here only)
The test-server copy; Netbeans stores a copy there on each save;
/var/www/vhosts/xyz/ (127.0.0.1/xyz/)
The SVN repository; I'll manually commit files to it after testing on the local webserver;
/var/svn/xyz/ (svn commit -m "my last change")
The SVN checkout on the live-server, which is the actual website;
/var/www/vhosts/xyz/ (svn update # xyz.com/)
I don't have a clue, how setup the "local copy" feature (which can also refer to some other machine) with Eclipse. If someone knows a way to reproduce the above workflow using Eclipse and not need to manually sync the files to the test-server, I#ll be glad to read it hereā¦
You could use a post-commit hook script on the CVS server to update (refresh) a working copy on var/www/html/. Every time you commit, the hook script would thus get the latest version of the files on the server and put them in var/www/html/.
I have the project in the remote server and i have only ssh access. How i can work with this project? I am looking for information for either PhpStorm or NetBeans.
You have several options, depending on your system.
You can rsync or scp up your files when you want to publish.
You can use version control (cvs, svn, git, mercurial, ...) and via ssh perform an "update" when you wish your code to go live.
You can set up a sshfs filesystem locally.
I don't know about NetBeans, but PhpStorm has a feature that allows uploading files as soon as they change to a server (via FTP or SSH).
I don't have a lot of experience with this feature but it does seem to work well. PhpStorm can also be configured to deploy changes that occurred outside (it seems to do so as soon as it regains focus). It also seems to properly delete files that have been deleted from the project, so it's a real sync, not just "upload".
See how to configure it under "To have PhpStorm upload changed files automatically" here: http://www.jetbrains.com/phpstorm/webhelp/uploading-and-downloading-files.html
I'm looking for an editor that can read and write remote PHP files via sFTP. I'm talking about not having a local copy of my PHP files.
But here is the tricky part : I'd like that editor to be aware of all the files in my projet, and provide me with intellisense-like auto-completion, classes structures, etc...Just like Eclipse PDT, Aptana and NetBeans do, but with the "remote project storage and awareness" feature.
Do you know about any editor with these features ?
Thanks !
Edit : I'm absolutely not working on my production server, but on a development server. It's mostly because I need to works under windows on my desktop PC and don't want host my projects locally for various compatibility and tools availability reasons, and use linux as a server OS.
May not be a good idea:
Warnings:
1) Disconnect:
What if you are coding and your connection gets lost, you may get a corrupted file or loose some work. Disconnects occur much more often that power loss in your home/office, and you can safeguard by using a small UPC - that will give a minute to save your work.
2) SCM:
Use git, mercurial, svn or what have you, to speed up deployment. Increases ability to share code, backup and roll backs.
3) Auto completion will not work very well over network connection, because ( at least in NetBeans) it scans your project to figure out what you want to auto-complete. It takes a few seconds even on a local machine.
Solution:
If after all of the above you still want to do it, you can trick your editor by mounting remote storage as a local drive. You didn't specify your OS but on Mac and Linux - you can easily do it - take a look at Fuse. http://fuse.sourceforge.net/
Khmm apperatnly there was an attempt to port Fuse to Windows:
http://fuse4win.4host.ru/
Hope that helps
Update
There are also a few commercial products - one was recommended by macworld I think ( they are both for Mac and Windows)
http://en.wikipedia.org/wiki/WebDrive
http://en.wikipedia.org/wiki/ExpanDrive
On Windows the Zeus editor can do seamless ftp/sftp editing.
These remote ftp files can also be defined to belong to a project/workspace.
But the Zeus PHP intellisensing will only work for local files.
You can use NetBeans for this, you will have your project saved locally but you can set to upload the file anytime when you save that file. Right click on your project, Properties, Run Configuration, Run As: Remote website. Click on Remote Connection: ... Manage and add your FTP account. Don't forget to set Upload files: to On Save. I have had no problem with this configuration and I am working for one year with NetBeans.
For quick editing I am using PSPad.
I don't think this is something that actually exists. Mainly because intellisense and class structures rely on being able to parse your complete project. Doing this over FTP would take way to long to actually be of any practical use.
You might be able to find an editor that will automatically upload any change you make locally though.
I'd second the comments about not working directly on your live environment.
As you've mentioned Eclipse / Aptana - perhaps consider using something like Git or SVN, with a post-commit hook to immediately publish to your live environment each time you commit. That way you reduce the risk by being able to easily roll back any changes that break your live server.
You can use Eclipse (with suitable git/svn plugin) to check out your entire site direct from the repository, and have all the code completion goodness you need. "Saving" is then just a case of committing your changes back to the repository, which would automatically update your server thanks to the post-commit hook.
It's still not ideal, and very risky to develop on a live server, but if you really have no preview environment, then this is perhaps slightly safer than simply working directly through ftp.
I'm curious why you'd need to not keep a local copy - yet you've said the project seems quite small - perhaps taking another approach to the problem would be safer?
I am new to Netbeans. Is it possible to work directly on the server files through sftp to avoid downloading/uploading each time. Will the intelisense work the same ?
If it is possible I can't find how to do that or what plug-in i need to use. And if it isn't what other free php IDE offers this option ?
So.
With Netbeans
To work directly through ftp/sftp on Netbeans 6.8
Open a new project and select "Php application from remote server"
It stills need a local storage for the files so that you can work on them so you need to specify a project name and it's local folder
Next step is the remote configuration: Click on the "Manage" button to add a new connection by giving it a name and selecting sftp or ftp. Then enter the connection configuration with the initial directory
Back on the remote configuration screen the upload directory must be the same as the "initial directory"
On the next screen you can retrieve all the project's sources
Once done each time you will save a file it will be automatically uploaded to the server. If not go in the project properties and check "Upload Files" is on "OnSave" mode in the "Run configuration" section.
PS:
I had problems with a "The authenticity of ... can't be established. RSA fingerkey is..." warning that kept appearing each time I saved. If so just create an empty and writable known_host file and point to it in the "Known host files" property of your remote connection, then restart Netbeans (seen on netbeans forum)
Edit: At this stage the behaviour still isn't quite what I am expecting since when you open a file netbeans will open the local copy and overwrite the remote copy when you save.
Edit2: Apparently you can not open the file directly from the server in Netbeans. You'll have to download the file before modifying it.
General solution
One workaround is to use an utility that will map the remote storage as a local drive. I know Fuse does it for Mac & Linux. I haven't found one for Windows yet.
Looks like NetBeans added it a few minor versions ago: http://blogs.oracle.com/netbeansphp/entry/sftp_support_added.
Just confirmed that this support is in the 6.8 version I have running.
The intelisense will work the same as long as you have all of the completable objects within your project scope, it won't pull libraries still on the server. Download a local copy of any 3rd party libraries your project may need and add them to your project's include path to get full code completion.