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

查看:35
本文介绍了是否有用于 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天全站免登陆