Repositories & pagination
The authenticated account comes back as an Owner:
$owner = Git::github()->user();
$owner->id; // "1"
$owner->name; // "jane-doe"
$owner->avatar; // avatar URL, or nullListing and pagination
List endpoints return a Page and never silently truncate: hasMore follows GitHub’s Link: rel="next" header, and a page size above 100 — the forges’ maximum — is capped to 100 (the Page reports perPage: 100). A page size below 1 throws InvalidArgumentException. Use allRepositories() for a lazily auto-paginating LazyCollection that requests the next page only when you reach it:
$github = Git::github();
$page = $github->repositories(perPage: 50); // Page<Repository>
$page->items; // list<Repository>
$page->hasMore; // bool
$page->page; // 1
$page->collect(); // Collection<Repository>
$page->first(); // ?Repository
$page->isEmpty(); // bool
count($page); // items on this page
foreach ($page as $repository) {
// a Page is iterable
}
foreach ($github->allRepositories() as $repository) {
// streams across all pages, one request at a time
}- items, perPage, page and hasMore — the page’s contents and position.
- collect() — the items as a Laravel Collection; first() — the first item or null.
- isEmpty() and count() — a Page is Countable and iterable, so foreach works directly.
A single repository and search
$repository = Git::github()->repo('acme/api')->get();
$repository->id; // provider id, as a string
$repository->path; // "acme/api"
$repository->name; // "api"
$repository->description; // ?string
$repository->defaultBranch; // "main"
$repository->owner->name; // "acme"
$repository->createdAt; // Carbon
$repository->lastActivityAt; // Carbon
Git::github()->repo($repository)->releases(); // a returned Repository opens its own handle
$results = Git::github()->searchRepositories('laravel', perPage: 10); // Page<Repository>For a GitHub App installation token, list what the installation can reach with installationRepositories() instead — see Scoped tokens & installations.
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.