Reputation: 43539
I'm setting up a system (PHP-based) that will let users instantly provision an SVN environment for use. It's an internal project so the users will mostly be internal users.
I haven't the foggiest idea where to even start. Are there SVN bindings for PHP, or am I going to have to use the svn
console command?
Upvotes: 4
Views: 680
Reputation: 6426
Here's one possibility. You'll have a couple steps here. First, you need to create the svn repo in your PHP action script, maybe something like:
$name = $_REQUEST['name'];
// gonna need some sanity checking on $name here. no '..', no '/'s, etc
$cmd = 'svnadmin create ' . escapeshellarg('/var/svn/' . $name) . ' --fs-type fsfs';
exec('sudo ' . $cmd, $output, $exitValue);
if ($exitValue != 0) {
// put the error message on the session, redirect out
}
$cmd = 'chown -R apache:apache ' . escapeshellarg('/var/svn/' . $name);
exec('sudo ' . $cmd, $output, $exitValue);
// error handling again
You'll need to set up sudo to allow your web server to run that svnadmin command. Then you'll need to drop in a new apache .conf snippet in /etc/httpd/conf.d:
<Location /$name>
DAV svn
SVNPath /var/svn/newproj
#AuthType Basic
#AuthName "SVN Repository"
#AuthUserFile /var/svn/${name}.passwd
#Require valid-user
</Location>
and restart Apache. Maybe create that newproj htpasswd file too for security. Be sure to check and sanitize all passed form values ($_REQUEST). Hope this gets you started.
Upvotes: 3
Reputation: 301257
Make it execute svnadmin create reponame
to create the repo. I don't think there are any libraries for this because you generally only find client side SVN libraries.
Just to make a suggestion "provisioning" Git repos is much simpler. And since there is no difference between client and server, your handling through git libraries ( http://code.google.com/p/git-php/ ) etc is very straightforward. Of course you may only want SVN repos, but if you have the choice, go for git.
Upvotes: 0