---
title: "Repositories & pagination — Git for Laravel | Roundly"
description: "Read the authenticated user, list repositories as typed pages or a lazy stream across every page, search, and fetch a single repository."
url: https://roundly-consulting.com/open-source/docs/git-for-laravel/repositories
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Git for Laravel](https://roundly-consulting.com/open-source/docs/git-for-laravel.md)

# Repositories & pagination

The authenticated account comes back as an Owner:

```php
$owner = Git::github()->user();

$owner->id;     // "1"
$owner->name;   // "jane-doe"
$owner->avatar; // avatar URL, or null
```

## Listing 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) — to 50 for Bitbucket’s pullRequests(), the most that endpoint takes. 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:

```php
$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.
- total — how many items the whole list holds when the forge says (GitHub Actions runs and jobs), else null; nextCursor — the next page’s cursor on a cursor-paged list (activity()), where page is always 1.
- 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

```php
$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
$repository->private;        // ?bool — GitLab counts internal as private
$repository->language;       // ?string — null on GitLab
$repository->webUrl;         // ?string — the repository's page on the forge

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 crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/git-for-laravel.md)
