Recover corrupted php files in netbeans - php

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.

Related

restore php projects when re-install wampserver

I forced to reinstall wamp on my pc. but i forgot to copy all php project on www folder on wamp and when install wamp again realize that all my php files are lose.
Can someone tell me how to restore it. I do in big trouble
Thank you.
You replaced some data in a directory, even if you, recover your data, they are maybe damaged.
But
Comfy File Recovery
is the application you can recover deleted folder, you should search for a recovery applications
NOTE:
I highly recommend don't waste your time to recover the codes that even you didn't get back up or push them in github or gitlab you will face a lot of troubles about your codes and databases...

Workflow for PHP website development with multiple developers & designers

I thought this had to be a common problem, but I was not able to find an easy solution. The problem is, we are working with multiple people on developing a website, without any version control involved. Which leads to obvious problems with conflicting edits and someone messing up the whole site with no simple way to recover. Currently some work with Filezila + Notepad++ directly downloading, additing and uploading the files.
Others work with Netbeans on their local copy and upload the files automatically when saving.
What I would like to do now is intruduce a version control system that still lets everyone work on the live system, but checks for conflicts and allows to rollback files to previous versions.
I tried to set up GIT with a post-receive hook that copies everything to the webroot, but failed in doing so. Besides I think SVN might be a better solution because everyone has just to checkout/commit instead of pull/commit/push.
Is it possible to set up GIT/SVN the way I like to?
Is there a better solution?
I have an SVN server setup and a cron job on the dev server to pull the latest revision out every 60 seconds. Then I have another script on the live server that isn't croned but I can manually run which updates the live server to the specified revision when I request it.
This allows the devs to commit and automatically test on the dev server pretty much real time and then when we've reviewed the code changes etc on the dev server and we're happy with it then I manually run the update on the live server.
The "common" problems come from you letting them work on live website ...
A developer on live will always find a way to ruin your day!

netbeans remote php workflow

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.

Working on PHP projects on a remote dev server via sFTP

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?

What's the best way to use SVN to version control a PHP site?

I've always just FTPed files down from sites, edited them and put them back up when creating sites, but feel it's worth learning to do things properly.
I've just commited everything to a SVN repo, and have tried sshing into the server and checking out a tagged build, as well as updating that build using switch.
All good, but it's a lot lot slower than my current process.
What's the best way to set something like this up? Most of my time is just bug fixes or small changes rather than large rewrites, so I'm frequently updating things.
You don't necessarily need to use SVN to deploy the files to the server. Keep using FTP for that and just use SVN for revision history.
You should look at installing rsync to upload changes to your server.
Rsync is great because it compares your local copy of the repo to the copy that's currently on the server and then only sends files that have changed.
This saves you having to remember every file that you changed and selecting them manually to FTP, or having to upload your whole local copy to the server again (and leaving FTP to do the comparisons).
Rsync also lets you exclude files/folder (i.e. .svn/ folders) when syncing between your servers.
I'd recommend you keep using Subversion to track all changes, even bug fixes. When you wish to deploy to your production server, you should use SSH and call svn update. This process can be automated using Capistrano, meaning that you can sit at your local box and call cap deploy -- Capistrano will SSH into your server and perform the Subversion update. Saves a lot of tedious manual labor.
For quick updates I just run svn update from the server.
Sometimes for really really quick updates I edit the files using vim and commit them from the server.
It's not very proper, but quick and quite reliable.
If you want to do this properly, you should definitely look into setting up a local SVN repository. I would also highly recommend setting up a continuous integration (CI) server such as cruise control, which would automatically run any tests against your PHP code when ever you check in to svn. Your CI server could also be used to publish your files via FTP to your host at the click of a button, once it has passed the tests.
Although this sounds like a lot of work, it really isn't and the benefits of a smooth deployment process will more than pay for itself in the long run.
For my projects, I usually have a repo. On my laptop is a working copy, and the live website is a working copy. I make my changes on the local copy, using my local webserver. When everything is tested and ready to go, I commit the changes, then I ssh into the remote server and svn update.
I also keep a folder in this repository which contains sql files of any changes I've made to the database structure, labelled according to their revision number. For instance, when I commit Revision 74 and it has a couple extra columns in one of the tables, included in the commit will be dbupdates/rev74.sql. That way, after I do my svn update, all I just have to run my sql file (mysql db_name -p -u username < dbupdates/rev74.sql) and I'm good to go.
If you want to get real funky with it, you could use a build script to get the current version from SVN, then compile your PHP code, then on a successful build, automatically push the changes to your server.
This will help in debugging and may make your code run faster. Also, getting into the build habit has really improved my coding over just pushing the PHP straight to the server and debugging via Firefox.
The benefits of source control reveal themselves as the complexity of the project and number of developers increase. If you are working directly on a remote server, and are only making quick patches most of the time, source control might not be worth the effort to you.
Preferably, you should be working from a local working copy of the repository (meaning you should also set up a local server). Working against a remote server using SVN as the only means to update it would slow you down quite considerably.
Having said that, working with SVN (or any other source control) will yield many benefits in the long run - you have a complete history of changes, you can always be sure the server is up-to-date (if you ran update) and if you add more developers to the project you can avoid costly source overwrites from each other.
What I do at work, is use FTP to upload changes to a test server. Then when I am finished with the section of the site that I was working on, I commit the changes and update both. Sometimes, if I am working on something and I change a lot of files in different directories, I commit it and update the test server. But I don't update the production server. But I am the only programmer here, I wouldn't recommend committing possibally buggy code if there is more than one programmer.
I use ZendStudio for Eclipse (currently version 6.1). And I use SVN to keep my source codes available. Initially I thought the process was somewhat slow due to commit process (and entering commit comment) and wait until it stops.
However after learning that Ctrl+Alt+C to Commit and check 'Always run in Background', the process doesn't slow at all.
Plus, I do run everything locally, then only SSH after a while.
I did a post-commit hook to automatically update my web. It´s fast but you can make mistakes.
IF on a *nix server AND you have the appropriate SSH access AND you have space to keep multiple copies of the website, THEN the single most useful versioning technique I have found is to use a symbolic link to point to the "current" version of the website. (You can still use SVN to version source code -- this is a way to easily/instantly switch between versions of the website on the server.)
Set up the webserver to point to /whatever.com as the root of the website.
Have a folder like /website/r1v00 to which you FTP the website files, then create a symlink called "whatever.com" that points to /website/r1v00
When you have an updated version of the website, create another folder called /website/r1v001, FTP all the files for the updated site, then change the symlink for "whatever.com" to now point to /website/r1v01. If there are any problems with the new site, you can back it out instantly by simply pointing the "whatever.com" symlink back to /website/r1v00
Of course, you can/should set up scripts to automate the creation and switching of the symlink. In my case, I have an "admin" page written in PHP that lists all the available versions, and allows me to switch to any of them. This technique has saved my bacon several times...!
Obviously this does not address any issues with versioning database schemas or database content.

Categories