PHP Version Control

I like version control systems. They are very useful, not only for keeping older versions of files, but also for easily keeping directories synchronized on multiple machines. The problem is that you have to run a server, such as subversion or CVS to be able to use it. However, not everybody has a machine to his/her disposal that is up 24/7. About “a year ago”: I mentioned a simple solutions for this. Why not write a version control system in PHP? A host that supports PHP is very cheap these days. Why not run a webservice on PHP that acts as a backend server for your version control?

One guy e-mailed me back then and said he would start working on it. I haven’t heard of him since. This morning I felt like giving it a shot myself. I spent a couple of hours on it and got a basic system running. This is how it works and what it does right now:

It’s a single PHP script that takes advantage of the “IXR_Library”:, which I use as an XML-RPC server implementation library for PHP. All I had to do was implementing the storing and retrieving of files. For this I use the file system. To set up a repository, all you have to do is create an empty directory and chmod it to 777. For the front-end (on your own computer) I wrote a simple client script in Python. It allows you to talk to the PHP version control script. It seems to work quite fine so far.

This is what works (at this moment it’s only about 300 lines in total, client and server together):
* Check-out
* Update (which check which files have changed on the repository and downloads the new versions)
* Check-in (uploads files that you have modified). On the server side all older versions of a file are kept.

What basically needs to be done is adding authentication (because everybody can do anything on the repository now), add security checks (it’s still rather insecure), add checks that warn people if they’re checking in a file that since has been checked-in by somebody else, allow to retrieve older versions of files and the usual diff and merge functionality.

I in no way intend to compete with products like Subversion or CVS. The idea is that it will be a light-weight, simple multi-user version control system so that everybody can enjoy the advantages of basic version control.