I was trying to interact with my subversion repositories using PHP yesterday and I knew that PECL has a extension named “SVN” for PHP users. So I tried to install in in my machine by when I tried to install it with the following command it always failed saying “unable to locate svn_client.h“
sudo pecl install -f svn
Then I googled for some time to find out which package actually and I found that it is a part of libsvn which I didnt install in my machine which has ubuntu 7.10. so I found the appropriate package using the following command and it obviously locate the appropriate lib to install, which is “libsvn-dev“
sudo apt-cache search libsvn
After that I just installed it via the standard procedure “sudo apt-get install libsvn-dev” and then tried to install the pecl extension once again. And whoa!, it works.
Here’s a small snippet to find out the difference of a single file from the repository under two separate revisions. in the following example svn_diff function returns two streams. one of them contains the difference and another one contains the error block.
<?php
list($diff,$error) = svn_diff(”http://orchidframework.googlecode.com/svn/trunk/app/config/configs.php”,
52,
“http://orchidframework.googlecode.com/svn/trunk/app/config/configs.php”,
61);
echo “<pre>”;
fpassthru($diff);
?>
Easy, huh?














4 responses so far ↓
butters // April 21, 2008 at 7:13 pm
yeah, thats easy peasy. thanks for this hint. altough i’m using git nowadys…
Philip Olson // April 22, 2008 at 9:50 pm
This blog post inspired us finding a bug in the official PECL SVN documentation… we forgot to include the install file into the docs during the restructuring but it’s now fixed in CVS. It mentions libsvn, so that’s good.
How to make your own springloops in PHP « The Storyteller // April 27, 2008 at 3:51 pm
[...] percent appropriate for this work. Yup, I am talking about “SVN” extension. You have to install this extension to use it with your PHP code. Once you are done with installing it, now you got the complete power [...]
Shaikh Sonny Aman // August 5, 2008 at 5:26 pm
i was looking for a svn api for php and this post was in great help
Leave a Comment