Search code examples
phpclasssvninclude

Including the SVN class in a PHP Project


So this probably has a simple answer, but I'm not finding it anywhere.

I have the following code:

function getSVN(){
    $svn = new SVN; 
    $log = $svn->log('https://svn.repo/trunk/', SVN::HEAD); 
}

Not surprisingly, I get the following error:

Fatal error: Class 'SVN' not found

So I tried to include it using:

use SVN; 

But I got:

Warning: The use statement with non-compound name 'SVN' has no effect

What's the proper way to include PHP's SVN class?


Solution

  • The SVN PHP client requires an additional PHP extension to be loaded.

    http://php.net/manual/en/svn.installation.php has some general installation instructions but the real gold is in the comments.

    Aptitude systems (incl. Ubuntu)

    sudo apt-get php5-svn Aptitude tends to resolve dependencies so we're good in that front.

    Yellowdog Updater, Modified (yum) systems

    yum install subversion subversion-devel neon neon-devel

    pecl install svn

    Windows

    Download the DLL if you can find one. Otherwise compile from source.

    Works on all systems

    Compile from source

    Following all this you need to ensure that either:

    1) There is a relevant entry in php.ini which enables this extension: e.g. extension=svn.so (or DLL) 2) There is a relevant configuration .ini file which is included with php (the path where this should be is stated in phpinfo();)

    In any case the extension needs to show up in the php -m list