且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有适用于GIT的PHP api?

更新时间:2023-02-16 15:51:38

快速搜索即可找到一个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.