konekt/git-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

konekt/git-php

Composer 安装命令:

composer require konekt/git-php

包简介

Easy to use GIT wrapper for PHP.

README 文档

README

Tests Packagist Stable Version Packagist downloads StyleCI MIT Software License

This repository was forked from bit3/git-php at its version 1.5.0.

GIT Wrapper for PHP

This is a lightweight wrapper, providing the git commands in PHP.

Examples

The API use command builders, that allow you to build a command and execute it one time.

The main synopsis is:

$git->command()->option()->execute();

$git->command() will create a new command, *->option() will add an option to the command and *->execute() will finally execute the command.

The naming of commands and options follow the git naming. If you search for documentation of a specific command or option, just look into the git documentation. You will find the command/option there.

init a new git repository

GitRepository::in('/path/to/git/target/directory')->init()->execute();

clone a git repository

The clone command is named cloneRepository() because clone is a reserved word in PHP.

$git = GitRepository::in('/path/to/repo');
$git->cloneRepository()->execute();

describe

$annotatedTag   = $git->describe()->execute();
$lightweightTag = $git->describe()->tags()->execute();
$recentRef      = $git->describe()->all()->execute();

set remote fetch url

$git->remote()
    ->setUrl('origin', 'git@github.com:bit3/git-php.git')
    ->execute();

set remote push url

$git->remote()
    ->setPushUrl('origin', 'git@github.com:bit3/git-php.git')
    ->execute();

add new remote

$git->remote()
    ->add('github', 'git@github.com:bit3/git-php.git')
    ->execute();

fetch remote objects

$git->fetch()->execute('github');

checkout

$git->checkout()->execute('hotfix/1.2.3');

checkout specific path

$git->checkout()->execute('hotfix/1.2.3', '/fileA', '/fileB', '/dir/fileC');

push objects

$git->push()->execute('github', 'hotfix/1.2.3');

add file to staging index

$git->add()->execute('file/to/add.ext');

remove file

$git->rm()->execute('file/to/remove.ext');

commit changes

$git->commit()->message('Commit message')->execute();

create a tag

$git->tag()->execute('v1.2.3');

Convenience and shortcut methods

list remotes

$remotes = $git->remote()->getNames();

// array(
//     'origin',
//     'composer',
// )

list branches

$remotes = $git->branch()->getNames();

// array(
//     'master',
//     'hotfix/1.2.3',
// )

list remote tracking branches

$remotes = $git->branch()->remotes()->getNames();

// array(
//     'origin/master',
//     'origin/hotfix/1.2.3',
//     'origin/release/4.5.6',
// )

list branches including remote tracking branches

$remotes = $git->branch()->all()->getNames();

// array(
//     'master',
//     'hotfix/1.2.3',
//     'remotes/origin/master',
//     'remotes/origin/hotfix/1.2.3',
//     'remotes/origin/release/4.5.6',
// )

get modification status

$status = $git->status()->getStatus();

// array(
//     'existing-file.txt'      => array('index' => 'D',   'worktree' => false),
//     'removed-but-staged.txt' => array('index' => 'D',   'worktree' => 'A'),
//     'staged-file.txt'        => array('index' => false, 'worktree' => 'A'),
//     'unknown-file.txt'       => array('index' => '?',   'worktree' => '?'),
// )

get index modification status

$status = $git->status()->getIndexStatus();

// array(
//     'existing-file.txt'      => 'D',
//     'removed-but-staged.txt' => 'D',
//     'staged-file.txt'        => false,
//     'unknown-file.txt'       => '?',
// )

get worktree modification status

$status = $git->status()->getWorkTreeStatus();

// array(
//     'existing-file.txt'      => 'worktree' => false,
//     'removed-but-staged.txt' => 'worktree' => 'A',
//     'staged-file.txt'        => 'worktree' => 'A',
//     'unknown-file.txt'       => 'worktree' => '?',
// )

konekt/git-php 适用场景与选型建议

konekt/git-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.61k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 11 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 konekt/git-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 konekt/git-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 konekt/git-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-09