检测服务器上的 svn 是否可用(在 PHP 中)

发布于 2025-01-07 12:27:00 字数 291 浏览 4 评论 0原文

我运行一个开源 PHP 脚本,该脚本正在各种服务器环境中使用。我需要在 PHP 中检测 svn 命令在服务器上是否可用。我的想法是,我将使用它作为下载安装/升级组件文件的主要方法,并使用旧方法(手动下载)作为辅助方法。

我知道我可以使用 exec() 或 system() 命令通过 PHP 调用svn导出,但我真正寻找的是一个命令行函数来测试 SVN 的存在,例如:

exec( “测试 svn”);

(理想情况下)它会输出一个布尔值或其他东西。

有什么建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北斗星光 2025-01-14 12:27:00
function hasSvn() {
  return shell_exec('which svn') != '';
}
function hasSvn() {
  return shell_exec('which svn') != '';
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文