Access git repositories (GitHub, GitLab, Bitbucket) through a single Laravel-native API.
roundly-consulting/git-for-laravel is a Laravel package for access git repositories (github, gitlab, bitbucket) through a single laravel-native api..
It currently has 5 GitHub stars and 27 downloads on Packagist (latest version 1.2.2).
Install it with composer require roundly-consulting/git-for-laravel.
Discover more Laravel packages by roundly-consulting
or browse all Laravel packages to compare alternatives.
Last updated
One Laravel-native API for GitHub, GitLab and Bitbucket: page through repositories and commits, read pull requests, issues, releases and files, open and merge pull requests, receive signed webhooks as typed events, and authenticate with tokens, GitHub Apps or OAuth — every answer a typed, provider-agnostic data object.
Requires PHP 8.4, Laravel 12 or 13.
composer require roundly-consulting/git-for-laravel
Put an access token in .env (GITHUB_TOKEN, GITLAB_TOKEN or BITBUCKET_TOKEN); without
one, only public repositories can be read.
Pick a forge and scope it to one repository:
use RoundlyConsulting\Git\Facades\Git;
$repo = Git::github()->repo('acme/app'); // also Git::gitlab(), Git::bitbucket() — see below
$repo->get()->defaultBranch; // "main"
$repo->pullRequests('open'); // Page<PullRequest>
$repo->contents('composer.json')->content; // decoded file contents
foreach ($repo->commits()->branch('main')->since(now()->subWeek())->lazy() as $commit) {
$commit->sha; // streams across every page
}
Writes take typed input objects:
use RoundlyConsulting\Git\Dto\Input\{NewBranch, NewFile, NewPullRequest};
use RoundlyConsulting\Git\Enums\MergeMethod;
$repo->createBranch(new NewBranch('feature/ci', 'main'));
$repo->createFile(new NewFile('ci.yml', $yaml, 'Add CI', 'feature/ci'));
$pr = $repo->createPullRequest(new NewPullRequest('Add CI', 'feature/ci', 'main'));
$repo->pullRequest($pr->number)->comment('Ready to ship');
$repo->pullRequest($pr->number)->merge(MergeMethod::Squash); // the merge commit's sha
Not every forge offers every call: GitLab cannot merge() here, and Bitbucket has no
contents(), since() filter, createBranch(), createFile() or merge(). Ask
Git::bitbucket()->supports(Feature::…) first — an unsupported call throws
FeatureNotSupportedException.
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/git-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
The MIT License (MIT). See LICENSE.md.