Table of Contents
PHP/Installing_SVN_Extension
Installation
The latest release of the SVN extension for PHP is 0.3, however various versions have some pretty major bugs:
- 0.2 won't install on Ubuntu. It complains during compilation that it can't find
apr.h
- 0.3 has a bug in the svn_log() function that prevents it returning an array of changed paths for each revision, like the documentation suggests it should. This was broken a mere 2 weeks before the 0.3 release, and fixed about a month after the release.
Since 0.2 and 0.3 are unusable (and I don't want to consider 0.1), you'll have to install the latest CVS version instead.
- First, get some pre-requisites:
sudo apt-get install libsvn1 libsvn-dev php5-dev build-essential
- Then get the CVS HEAD revision and change into the directory it creates:
cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/svn cd pecl/svn
- Install it with PECL:
sudo pecl install package2.xml
- Add the “extension” line to your php.ini file:
sudo echo “extension=svn.so” » /etc/php5/apache2/php.ini
- And reload Apache:
sudo /etc/init.d/apache2 force-reload
Other Notes
The PHP docs haven't been updated with information about the latest builds.
svn_log()
Function prototype is now: array svn_log ( string $repos_url [, int $start_revision=HEAD [, int $end_revision=INITIAL [, int $limit [, int $flags ]]]]) Meaning that the results of this function are no longer either all revisions or a single revision.
The
$flags
argument is a bitwise value that lets you change the output. Available flags, including their corresponding
svn
command-line switches, as stated in the extension's source are: SVN_NON_RECURSIVE (–non-recursive) SVN_DISCOVER_CHANGED_PATHS (–verbose) SVN_OMIT_MESSAGES (–quiet) SVN_STOP_ON_COPY (–stop-on-copy) SVN_ALL (–verbose in svn status) SVN_SHOW_UPDATES (–show-updates) SVN_NO_IGNORE (–no-ignore) The default is currently <code>SVN_DISCOVER_CHANGED_PATHS | SVN_STOP_ON_COPY</code>, so to stop it returning the changed paths, for example, pass <code>SVN_STOP_ON_COPY</code>, or to disable all flags entirely just pass <code>0</code>.
Constants
SVN_REVISION_HEAD (Pass to functions expecting a revision number and the HEAD revision will be used instead) SVN_REVISION_INITIAL (Pass to functions expecting a revision number and the initial revision will be used instead)