Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Git Laravel Package

sebastianfeldmann/git

PHP library to access and interact with Git repositories. Provides a simple API for common Git commands and info (status, log, branches, tags), ideal for build scripts, CI tooling, and automation where you need Git data without shelling out manually.

View on GitHub
Deep Wiki
Context7

git - a handy git wrapper

Latest Stable Version Minimum PHP Version Downloads License Build Status Scrutinizer Code Quality Code Coverage

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');
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport