sebastianfeldmann/git
Composer 安装命令:
composer require sebastianfeldmann/git
包简介
PHP git wrapper
关键字:
README 文档
README
This lib is used to execute git commands directly from PHP via a defined api.
All you have to do is setup a Repository object, retrieve a command Operator
and fire away. Each git command like git config or git log is handled
by a separate Operator. Follow the next steps to give it a try.
Installation
The git package is installable via composer. Just run the following command.
$ composer require sebastianfeldmann/git
Usage
Setup the Repository
$repoRootPath = '/var/www/my-project'; $gitRepository = new Git\Repository($repoRootPath);
Retrieve the needed Operator
$log = $gitRepository->getLogOperator();
Get files and commits since some tag
$files = $log->getChangedFilesSince('1.0.0'); $commits = $log->getCommitsSince('1.0.0');
Copy Paste Example
use SebastianFeldmann\Git; require __DIR__ . '/../vendor/autoload.php'; // path to repository without .git $repoRootPath = '/path/to/repo'; $gitRepository = new Git\Repository($repoRootPath); // get files and commits since hash or tag $log = $gitRepository->getLogOperator(); $files = $log->getChangedFilesSince('1.0.0'); $commits = $log->getCommitsSince('1.0.0'); // check the index status $index = $gitRepository->getIndexOperator(); $files = $index->getStagedFiles();
Available operators
- Config - Access all git settings e.g. line break settings.
- Diff - Compare two versions.
- Index - Check the staging area.
- Info - Access the current state like branch name or commit hash.
- Log - Returns list of changed files and other git log information.
Example commands
Get the current tag:
// git describe --tag
$tag = $infoOperator->getCurrentTag();
Get tags for a given commit:
// git tag --points-at HEAD
$tags = $infoOperator->getTagsPointingTo('HEAD');
Get the current branch:
// git rev-parse --abbrev-ref HEAD
$branch = $infoOperator->getCurrentBranch();
Get a list of staged files:
// git diff-index --cached --name-status HEAD
$files = $indexOperator->getStagedFiles();
Get all current git settings:
// git config --list
$config = $configOperator->getSettings();
Get all changed files since a given commit or tag:
// git log --format='' --name-only $HASH
$files = $logOperator->changedFilesSince('1.0.0');
Get differences between two versions
// git diff '1.0.0' '1.1.0'
$changes = $diffOperator->compare('1.0.0', '1.1.0');
sebastianfeldmann/git 适用场景与选型建议
sebastianfeldmann/git 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.71M 次下载、GitHub Stars 达 47, 最近一次更新时间为 2017 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「git」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sebastianfeldmann/git 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sebastianfeldmann/git 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sebastianfeldmann/git 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easily manage git hooks in your composer config
MediaWiki extension that allows embedding external content, specified by URL, into your wiki pages
Nagios plugin to verify a git repository.
GitHub Webhook Listener with plugin-based API for creating your own triggerered actions
This project will create a WordPress base installation using wp-cli/wp-cli package and using vlucas/phpdotenv package to expose configuration values in PHP $_ENV super global.
A PHP (read-only) wrapper for the Git command line utility
统计信息
- 总下载量: 7.71M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 48
- 点击次数: 16
- 依赖项目数: 15
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-16