PHP frontend to Subversion (SVN)
Posted by Robert Swarthout | Filed under Apache, PHP, Subversion
So over the last week I have been working on and off with a PHP frontend to SVN. The frontend needed to be designed in such a way that each developer could access their working copies and make the full range of actions against them. I decided to also use an AJAX setup so that pages would be quickly loaded and updated by a single toggle of a folder. The first issue that I had to deal with was when a SVN command was issues it needed to be issued as the owner of the code so that SVN could track edits correctly. After googling around for a bit I quickly realized that there was not a viable Apache MPM that would serve virtual hosts under different users and groups. Then the light bulb flipped on, setup a proxy and redirect requests to developer.dev.domain.com to its own instance of apache running as the user and group ‘developer’. This would ensure that all SVN commands would run as ‘developer’ when executed. I then moved onto setting up the interface. The features that are working at this time are:
- create working copy from repository (svn checkout)
- delete working copy
- svn add
- svn blame
- svn commit
- svn copy
- svn delete
- svn diff
- svn move
- svn propset
- search files (via a grep/find combination, omitting .svn folders)
- svn log
- svn rename
- svn status
- update local working copy
- update stage environment
- publish stage environment
A few things that I learned while working with doing the SVN commands was that when executing a command via the php function exec() I need to add the flag –config-dir=$USER_HOME_DIR/.subversion (or where ever the users .subversion folder is located). Also if a command does not seem to be executing correctly you can add “2>&1″ without quotations to the command being run and it will return any error messages through the $ouput variable for exec();
February 1st, 2007 at 11:45 am
Hi Robert,
Have you looked at VersionControl_SVN in PEAR? Has a few bugs (that are fixed in a release on my HD), but may speed your process a bit.
-Clay
February 2nd, 2007 at 4:21 am
You might also check out (if you have not) websvn:
http://websvn.tigris.org/
February 2nd, 2007 at 9:08 am
I actually am all done with this little project. I looked at both the PEAR package as well as the websvn setup. In the end they did not do what I wanted them to do. The frontend I created actually is a bit different than the two mentioned above. This frontend actually runs on an instance of apache for each developer and executes the svn commands as that user. Basically it is a frontend for a remote working copy, if that makes any sense.
May 14th, 2007 at 3:40 pm
Hey, any chance that you’ll share the source for this? It’s pretty similar to something I’ve been thinking of making lately and I’d like to try it out and maybe help out.
May 20th, 2007 at 11:44 am
Yes, in the future I do plan on releasing it. The code needs to be cleaned up and some comments added. It is very proprietary right now.
June 30th, 2007 at 9:01 pm
It’s nice