是否有适用于GIT的PHP api? [英] Is there a PHP api for GIT?

查看:117
本文介绍了是否有适用于GIT的PHP api?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何API或php与GIT进行交互?

I wonder If there are any APIs or something for php to interact with GIT?

我想在网页上打印出有关分支机构,存储库等的信息.

I want to print out information about branches, repositories etcetc, on a web page.

这可能吗?

推荐答案

快速搜索即可找到一个github项目https://github.com/kbjr/Git.php -它具有一个PHP库,可使用proc_open访问git,并可以在git安全模式下使用.

A quick search turns up a github project https://github.com/kbjr/Git.php - which has a PHP library for accessing git using proc_open and usable in git safe mode.

它似乎很容易使用.根据api文档,您可以使用以下命令获取数组中的分支列表:

It seems to be fairly easy to use. According to the api documents, you'd be able to get a list of branches in an array with these commands:

require_once('Git.php');

$repo = Git::open('/path/to/repo');
$branch_array  = $repo->list_branches();

您将用自己的回购路径替代.您需要安装git命令才能使其正常工作.

You'd substitute your own repo path. You would need the git commands installed for that to work.

关于创建整个网页,有完整的系统-cgit,gitweb,gitphp和许多其他系统,因此在创建全新的页面之前,是否可以对其中的任何一个进行配置以满足您的需求可能值得考虑工具.

As for creating a whole web page, there are complete systems for this - cgit, gitweb, gitphp and a number of others so it may be worth considering if any of those could be configured to meet your needs before creating a completely new tool.

这篇关于是否有适用于GIT的PHP api?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆