Open source
Git for Laravel
composer require roundly-consulting/git-for-laravelOverview
A Laravel-native client for GitHub, GitLab and Bitbucket. Resolve a provider from the Git facade (or an injected GitManager), authenticate once — a token, an OAuth grant or a GitHub App — and read or write repositories, commits, pull requests, issues, releases, files and webhooks through one API that returns typed data objects. Signed inbound webhooks arrive as Laravel events, and a built-in fake lets you test it all without the network. MIT-licensed and built on Laravel’s own HTTP client with no third-party runtime dependencies — crypto, enums and rate limiting come from our own companion packages.
What you get
Three forges, one API
GitHub, GitLab and Bitbucket behind one Git facade — or an injected GitManager — so switching forge is a one-word change.
Typed, canonical data
Every result is a typed object with a normalized ResourceState, plus a raw() escape hatch for any unmodelled field.
Reads, writes and reviews
Repositories, commits, pull requests, issues, releases, files and diffs — and creating, reviewing and merging them.
Self-refreshing credentials
GitHub App installation tokens and OAuth tokens minted, cached and refreshed for you, scoped per repository.
Signed webhooks as events
Inbound webhooks verified in constant time and dispatched as typed Laravel events, plus idempotent one-call registration.
Quota-safe and resilient
Client-side pacing, adaptive Retry-After back-off, read retries and ETag caching — writes are never retried.
Testable without HTTP
Git::fake() swaps in a recording double for the facade and injected managers alike, with chainable seeders and call assertions.
Documentation
Installation
Install via Composer and optionally publish the config and webhook route stub — the service provider and Git facade are auto-discovered.
Configuration
Every config key and default — per-provider URLs, tokens, retries and rate limits, GitHub App and OAuth, caching, logging, webhooks, batching.
The Git facade
Everything starts at Git:: — a driver per forge, repo() and pullRequest() handles, installation lookups, webhook checks and a scope guard.
Without the facade
Inject GitManager instead of calling the facade, or drop to the flat Provider methods the handles wrap — same code, same fake.
Providers & credentials
Resolve GitHub, GitLab or Bitbucket from the Git facade, authenticate with a token, OAuth or GitHub App credential, or read public repos anonymously.
Repositories & pagination
Read the authenticated user, list repositories as typed pages or a lazy stream across every page, search, and fetch a single repository.
Branches & commits
List branches, filter commits by branch, author, path and date with a fluent query, page or stream them, and fetch a single commit.
Pull requests, issues & files
Read pull/merge requests, issues, tags, releases, decoded file contents, diffs, contributors and languages as typed objects.
Data model & raw payloads
Provider-agnostic objects with a normalized ResourceState, a raw() escape hatch for unmodelled fields, and clean array and JSON output.
Concurrent batch fetches
Fan many reads out over one Http::pool() round trip and get a keyed BatchResult that separates successes from per-key failures.
Write operations
Create branches, files, pull requests, comments, releases, tags and webhooks with validated input objects — writes are never retried.
Creating repositories
Create repositories under a user, an organization or from a template, with an initial commit and a chosen default branch.
Merging & reviewing PRs
Close, approve and merge pull requests pinned to a head SHA, publish a full review with inline comments, and read reviews back.
GitHub App & OAuth tokens
Self-refreshing GitHub App installation tokens and OAuth access tokens — minted, cached and refreshed for you, with an event on rotation.
Scoped tokens & installations
Narrow installation tokens to specific repositories, verify installations as the app itself, and send users to install your GitHub App.
Clone URLs
Build authenticated HTTPS clone URLs from a static token, an OAuth grant or a GitHub App installation token.
Webhooks
Receive signature-verified webhooks as typed Laravel events and register your endpoint on a repository idempotently in one call.
Retries, caching & rate limits
Read retries with backoff, ETag conditional caching, client-side pacing with adaptive back-off, rate-limit status and safe request logging.
Feature detection
Check what each provider supports before calling it, read the full capability matrix, and compare GitHub, GitLab and Bitbucket side by side.
Artisan commands
List repositories and commits, check rate-limit status, and register, list or delete repository webhooks from the command line.
Errors & exceptions
Every exception the package throws, when it is thrown, and how HTTP statuses from the forge map onto them.
Testing
Git::fake() records every provider call for the facade and injected managers — seed responses, run code without HTTP, assert what was sent.
Requirements
PHP 8.4+, Laravel 12 or 13, and four Roundly companion packages that Composer installs automatically.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.