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

Gitlib Laravel Package

gitonomy/gitlib

Gitonomy Gitlib is a PHP library for interacting with Git repositories programmatically. Read commits, trees, branches, tags and diffs; run Git commands via a clean API and work with local repos from your apps, tools, or CI scripts.

View on GitHub
Deep Wiki
Context7

Blaming files

Line-per-line iteration

To iterate on lines of a blame:

$blame = $repository->getBlame('master', 'README.md');

foreach ($blame->getLines() as $lineNumber => $line) {
    $commit = $line->getCommit();
    echo $lineNumber.': '.$line->getContent().'    - '.$commit->getAuthorName().PHP_EOL;
}

The getLines method returns an array indexed starting from 1.

As you can see, you can access the commit object related to the line you are iterating on.

If you want to access directly a line:

$line = $blame->getLine(32);

The Line object

LineObject represents an item of the blame file. It is composed of those informations:

$line->getCommit();  // returns a Commit
$line->getContent(); // returns text

// you can access author from commmit:
$author = $line->getCommit()->getAuthorName();

Group reading by commit

If you plan to display it, you'll probably need a version where lines from same commit are grouped.

To do so, use the getGroupedLines method that will return an array like this:

$blame = array(
    array(Commit, array(1 => Line, 2 => Line, 3 => Line)),
    array(Commit, array(4 => Line)),
    array(Commit, array(5 => Line, 6 => Line))
)
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.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver