roundly-consulting / git-for-laravel
Access git repositories (GitHub, GitLab, Bitbucket) through a single Laravel-native API.
Package info
github.com/roundly-consulting/git-for-laravel
pkg:composer/roundly-consulting/git-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- roundly-consulting/crypto-for-laravel: ^1.0
- roundly-consulting/enums-for-laravel: ^1.0
- roundly-consulting/http-client-rate-limits-for-laravel: ^1.0
- roundly-consulting/package-toolkit-for-laravel: ^1.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- nunomaduro/collision: ^8.5
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- roundly-consulting/testing-for-laravel: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Git for Laravel
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.
Installation
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.
Usage
Pick a forge and scope it to one repository:
use RoundlyConsulting\Git\Facades\Git; $repo = Git::github()->repo('acme/app'); // or Git::gitlab(), Git::bitbucket() $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
Documentation
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.
Support our work
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.
License
The MIT License (MIT). See LICENSE.md.