承接 dmamontov/git4p 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dmamontov/git4p

Composer 安装命令:

composer require dmamontov/git4p

包简介

A native PHP git library

README 文档

README

Status: No longer active / archived

Build Status Codacy Badge Codacy Badge StyleCI

Git4P

"Git4P" stands for "Git for PHP" and is a native PHP Git library that can access a Git repository without using external help like the standard git commands. It is geared towards server side (bare) repositories.

Please let me know how you're using this library.

Examples

Create a new bare repository

Git::init('/tmp/mytestrepo');

Add a simple blob

In this example the blob is 'orphaned', which means it is unreachable through any commits.

$git = Git::init('/tmp/mytestrepo');

$readme = "GIT4P\n=====\n\nThis is a simple test repo for git4p.\n";

$blob = new GitBlob($git);
$blob->setData($readme)
     ->store();

Full basic repository with a single commit

We programmatically create a blob (file), a tree (directory) that points to it and then a commit pointing to the tree. Finally we make sure the master branch points to this commit.

$git = Git::init('/tmp/mytestrepo');

$readme = "GIT4P\n=====\n\nThis is a simple test repo for git4p.\n";
$user = new GitUser();
$user->setName('Some User')
     ->setEmail('some.user@example.com')
     ->setTimestamp('1374058686')
     ->setOffset('+0200');

$blob = new GitBlob($git);
$blob->setData($readme)
     ->store();

$arr = ['README.md' => $b];
$tree = new GitTree($git);
$tree->setData($arr)
     ->store();

$commit = new GitCommit($git);
$commit->setTree($tree->sha())
       ->setMessage('Initial commit.')
       ->addAuthor($user)
       ->addCommiter($user)
       ->store();

$git->updateBranch('master', $commit->sha());

Note

This library currently has limited pack support. Reading in and listing packed refs is supported through GitRef but support for packed objects is not implemented yet.

Some TODOs

  • Add pack support
  • Add proper phpdoc blocks

统计信息

  • 总下载量: 76
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-24