I am developing a web application in PHP and JS. The software until recently was only being developed on and not being used by clients, so I could just change the script files directly. After the application went into release I just copied the application in a beta folder in which I could do changes. After testing the changes I manually selected the changed files and copied them into the release system.Well, I really think there must be a better approach to my problem, that does not include manually copying files from beta to release. I used git for projects to collaborate with other people, but those always were non web applications, that were not running, while changing them. Collaboration is not as important, for I am working alone, at least in the medium term. Are there approaches to use git oder something else for working web applications?As IDE I am using Netbeans, which is synchronized with the server.Edit: Currently the productive code is located in the htdocs folder of the webserver. A copy of the whole stuff is in htdocs/dev. I do changes on the code in dev via Netbeans, without any version control plug-in, it just synchronizes the project files via sftp with the files in dev. After changing I am able to test the changes using example.org/beta. If everything's fine I copy the changed files into the productive system.
How to version control a running web application?
version control;web applications;git;deployment
If, as you write, you directly edit files on the server over SFTP, your only option (as far as I can see) is to install git on the server, login via SSH and do all git operations locally. You'd have to create a repository on the server, add all your files and then commit regularly. In that case your working directory would be the directory where all the JS and PHP files live.However, I would not recommend this approach, as it has some problems. Among others, you need SSH login on the server, your git repo must be on the server, and if your application's files are spread over multiple directories, it gets difficult to put everything into one repository.What I would recommend instead is: Develop locally, then deploy to server.That means you install PHP, webserver etc. locally, then keep the code on your workstation and do most of your development there. Then you can alwso use git locally to version your code.Once a feature is ready, you deploy your code to the production web host, to make it go live (or to a test installation for final testing). This gives you much more flexibility while developing (easier to use various tools, like git, no need for constant server access, less risk to mess up the server while developing etc.).To do this, you need a local installation of PHP and all other required infrastructuresome, andsome kind of deployment system. Local installations of PHP are readily available (see for example the question PHP server on local machine? ).For deployment, there are many existing systems, and there are deployment solutions specifically for PHP. You could also just start out with a simple script that SFTPs everything to the server, and makes them live (restarts any services as required, clears caches etc.) and then go on from there.