Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if svn available on server (within PHP)

Tags:

php

svn

detection

I run an open source PHP script, which is being used on all sorts of server environments. I need to detect within PHP whether or not the svn command is available on the server. The idea is that I'll use it as the primary way to download files for installation / upgrading components, and use older methods (manual download) as a secondary method.

I know I can call svn export through PHP with the exec() or system() commands, but what I'm really looking for is a command line function to test for SVN's presence, like:

exec("test svn");

which would (ideally) output a boolean or something.

Any suggestions?

like image 895
benjamin.keen Avatar asked Dec 31 '25 12:12

benjamin.keen


1 Answers

function hasSvn() {
  return shell_exec('which svn') != '';
}
like image 148
quickshiftin Avatar answered Jan 02 '26 02:01

quickshiftin