PHPackages                             rummykhan/github-reader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rummykhan/github-reader

ActivePackage[API Development](/categories/api)

rummykhan/github-reader
=======================

Github Repository Reader.

0.0.2(8y ago)924MITPHPPHP &gt;=5.5.9

Since Oct 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/rummykhan/github-reader)[ Packagist](https://packagist.org/packages/rummykhan/github-reader)[ RSS](/packages/rummykhan-github-reader/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Github Repository Reader
========================

[](#github-repository-reader)

This package helps reading a complete github repository &amp; retrieve any file you want to. This package is a wrapper around [GrahamCampbell/Laravel-GitHub](https://github.com/GrahamCampbell/Laravel-GitHub), But this package is specifically for reading a Repository in its proper format using [Github Official API](https://developer.github.com/)

Github Official Format
----------------------

[](#github-official-format)

```
name: "LICENSE"
path: "LICENSE"
sha: "c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d"
size: 1110
url: "https://api.github.com/repos/rummykhan/github-reader/contents/LICENSE?ref=master"
html_url: "https://github.com/rummykhan/github-reader/blob/master/LICENSE"
git_url: "https://api.github.com/repos/rummykhan/github-reader/git/blobs/c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d"
download_url: "https://raw.githubusercontent.com/rummykhan/github-reader/master/LICENSE"
type: "file"
```

Only the type is changed for `directory` / `symlink`.

Installation
------------

[](#installation)

Install using composer

```
composer require rummykhan/github-reader php-http/guzzle6-adapter
```

Add Service Provider
--------------------

[](#add-service-provider)

Add `ServiceProvider` to `config/app.php` providers array.

```
\GithubReader\GithubReaderServiceProvider::class,
```

Add Facade
----------

[](#add-facade)

To use with Facade add

```
'GithubReader' => \GithubReader\Facades\GithubReader::class,
```

Publish the configuration (github.php)

Publish Config
--------------

[](#publish-config)

```
php artisan vendor:publish
```

This will publish `github.php` in `config/` directory.

Update Config
-------------

[](#update-config)

Since [Github has changed the api Rate Limit](https://developer.github.com/changes/2012-10-14-rate-limit-changes/) you may get exception for hourly rate limit reached. Then you need to [Register Github App](https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/registering-github-apps/)and add credentials in `config/github.php`.

```
'app' => [
    'clientId'     => 'xxx**************xxx',
    'clientSecret' => 'xxx**************xxx',
    'method'       => 'application',
    // 'backoff'      => false,
    // 'cache'        => false,
    // 'version'      => 'v3',
    // 'enterprise'   => false,
],
```

Reading Repository
------------------

[](#reading-repository)

Reading a repository is as straight forward as it could be.

```
$repository = app('github-reader')->read('rummykhan', 'github-reader');

dd($repository);
```

Getting content of a file
-------------------------

[](#getting-content-of-a-file)

```
$repository = app('github-reader')->read('rummykhan', 'github-reader');

$files = $repository->getFiles();

// This method will retrieve file from github
$file = $files->first()->retrieve();

dd($file->getContent());
```

Query Files
-----------

[](#query-files)

Since files and directories are instances of `Illuminate\Support\Collection`, You can query both files or dictionaries just like you query a `Illuminate\Support\Collection`

There are two ways you can query files.

```
$repository = app('github-reader')
        ->read('rummykhan', 'github-reader');

$file = $repository->getFiles()->where('name', 'LICENSE')->first();

dd($file);
```

**OR**

To query in Files just add `InFiles` to all the collection methods.

```
$repository = app('github-reader')
        ->read('rummykhan', 'github-reader');

$file = $repository->whereInFiles('name', 'LICENSE')->first();

dd($file);
```

Query Directories
-----------------

[](#query-directories)

```
$repository = app('github-reader')
        ->read('rummykhan', 'github-reader');

$dictionary = $repository->getDirectories()->where('name', 'src')->first();

dd($dictionary);
```

**OR**

To query in Dictionaries just add `InDictionaries` to all the Collection methods.

```
$repository = app('github-reader')
        ->read('rummykhan', 'github-reader');

$dictionary = $repository->whereInDictionaries('name', 'src')->first();

dd($dictionary);
```

Find a file in repository
-------------------------

[](#find-a-file-in-repository)

Since the structure of each item either File/Directory in the repository is like below.

```
name: "LICENSE"
path: "LICENSE"
sha: "c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d"
size: 1110
url: "https://api.github.com/repos/rummykhan/github-reader/contents/LICENSE?ref=master"
html_url: "https://github.com/rummykhan/github-reader/blob/master/LICENSE"
git_url: "https://api.github.com/repos/rummykhan/github-reader/git/blobs/c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d"
download_url: "https://raw.githubusercontent.com/rummykhan/github-reader/master/LICENSE"
type: "file"
```

We can find any all matching directory/files recursively.

```
$repository = app('github-reader')
        ->read('rummykhan', 'github-reader');

$found = $repository->find('type', 'file');

dd($found);
```

Third parameter in the find is to find recursively

```
$repository = app('github-reader')
        ->read('rummykhan', 'github-reader');

$found = $repository->find('name', 'File.php', true);

dd($found);
```

This `find` method will return a collection.

Available Methods
-----------------

[](#available-methods)

### 1. GithubReader\\RepositoryReader

[](#1-githubreaderrepositoryreader)

```
$reader = app('github-reader')
```

NamePurpose`init($organization, $repositoryName, $connection = null)`Initialize the repository with organization/user and repository name.`getConnection()`Getter for connection.`setConnection(string $connection)`Set the connection.`getOrganization()`Getter for Organization.`setOrganization(string $organization)`Setter for organization.`getRepositoryName()`Getter for repository name.`setRepositoryName($repositoryName)`Setter for repository name.`read($organization = null, $repositoryName = null, $connection = null)`read a repository completely.`readPath($path = null)`Read only certain path of the repository.To only use read path.

```
$directory = app('github-reader')
	->setOrganization('rummykhan')
	->setRepositoryName('github-reader')
	->readPath('src');
```

### 2. GithubReader\\Github\\Directory Or Repository

[](#2-githubreadergithubdirectory-or-repository)

```
$repository = app('github-reader')->read('rummykhan','github-reader');
```

NamePurpose`getFiles()`Get all files in that directory.`getDirectories()`Get all directories in that directory.`listAll()`Get all files and directories in that directory.`retrieve()`Alias of `listAll()`.`find($key, $name, $all = true)`Find in all files and directories if `$all=true` it will find recursively.`findDirectory($key, $name, $all = false)`Find in directoris and if `$all=true` it will find recursively.`findFile($key, $name, $all = false)`Find in files and if `$all=true` it will find recursively.`toArray()`Convert the object to array representation.`toJson($options = 0)`Convert the object to JSON representation.### 3. GithubReader\\Github\\File

[](#3-githubreadergithubfile)

```
$repository = app('github-reader')->read('rummykhan','github-reader');

$file = $repository->getFiles()->first();
```

NamePurpose`retrieve()`It will give you instance of `Github\Github\FileContent`.### 4. GithubReader\\Github\\FileContent

[](#4-githubreadergithubfilecontent)

```
$repository = app('github-reader')->read('rummykhan','github-reader');
$file = $repository->getFiles()->first();
$fileContent = $file->retrieve();
```

NamePurpose`getContent()`It will give content of file in plain text.### Contact

[](#contact)

[rehan\_manzoor@outlook.com](mailto://rehan_manzoor@outlook.com)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

2

Last Release

3119d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ec5bb20e8a7ab8406ddae6110cff6c6f6e277ae09bda845006b25aabac0126a?d=identicon)[rummykhan](/maintainers/rummykhan)

---

Top Contributors

[![rummykhan](https://avatars.githubusercontent.com/u/12664104?v=4)](https://github.com/rummykhan "rummykhan (20 commits)")

---

Tags

githubgithub-readerlaravelreadergithubrepository

### Embed Badge

![Health badge](/badges/rummykhan-github-reader/health.svg)

```
[![Health](https://phpackages.com/badges/rummykhan-github-reader/health.svg)](https://phpackages.com/packages/rummykhan-github-reader)
```

###  Alternatives

[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[art4/json-api-client

JSON API client

139791.3k7](/packages/art4-json-api-client)[phpsa/laravel-postman

Export laravel API routes to postman

1014.7k](/packages/phpsa-laravel-postman)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
