{"id":19133916,"url":"https://github.com/rummykhan/github-reader","last_synced_at":"2025-07-07T22:07:25.703Z","repository":{"id":62538168,"uuid":"106907562","full_name":"rummykhan/github-reader","owner":"rummykhan","description":"Laravel Github Reader - A Laravel Package to Read Github Repositories","archived":false,"fork":false,"pushed_at":"2017-10-30T08:59:35.000Z","size":29,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T19:27:39.886Z","etag":null,"topics":["github","github-reader","laravel"],"latest_commit_sha":null,"homepage":"http://www.rehanmanzoor.me","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rummykhan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-14T07:24:23.000Z","updated_at":"2024-08-10T18:16:45.000Z","dependencies_parsed_at":"2022-11-02T16:15:19.958Z","dependency_job_id":null,"html_url":"https://github.com/rummykhan/github-reader","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rummykhan/github-reader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rummykhan%2Fgithub-reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rummykhan%2Fgithub-reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rummykhan%2Fgithub-reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rummykhan%2Fgithub-reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rummykhan","download_url":"https://codeload.github.com/rummykhan/github-reader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rummykhan%2Fgithub-reader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264152249,"owners_count":23564908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-reader","laravel"],"created_at":"2024-11-09T06:24:23.412Z","updated_at":"2025-07-07T22:07:25.683Z","avatar_url":"https://github.com/rummykhan.png","language":"PHP","readme":"# Github Repository Reader\n\nThis package helps reading a complete github repository \u0026 retrieve any file you want to.\nThis 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/)\n\n## Github Official Format\n\n```bash\nname: \"LICENSE\"\npath: \"LICENSE\"\nsha: \"c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d\"\nsize: 1110\nurl: \"https://api.github.com/repos/rummykhan/github-reader/contents/LICENSE?ref=master\"\nhtml_url: \"https://github.com/rummykhan/github-reader/blob/master/LICENSE\"\ngit_url: \"https://api.github.com/repos/rummykhan/github-reader/git/blobs/c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d\"\ndownload_url: \"https://raw.githubusercontent.com/rummykhan/github-reader/master/LICENSE\"\ntype: \"file\"\n```\nOnly the type is changed for `directory` / `symlink`.\n\n## Installation\n\nInstall using composer\n\n```php\ncomposer require rummykhan/github-reader php-http/guzzle6-adapter\n```\n\n## Add Service Provider\nAdd `ServiceProvider` to `config/app.php` providers array.\n\n```php\n\\GithubReader\\GithubReaderServiceProvider::class,\n```\n\n## Add Facade\nTo use with Facade add\n\n```php\n'GithubReader' =\u003e \\GithubReader\\Facades\\GithubReader::class,\n```\n\nPublish the configuration (github.php)\n\n## Publish Config\n\n```php\nphp artisan vendor:publish\n```\nThis will publish `github.php` in `config/` directory.\n\n## Update Config\n\nSince [Github has changed the api Rate Limit](https://developer.github.com/changes/2012-10-14-rate-limit-changes/) you may get exception for hourly\nrate 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/)\nand add credentials in `config/github.php`.\n\n```php\n'app' =\u003e [\n    'clientId'     =\u003e 'xxx**************xxx',\n    'clientSecret' =\u003e 'xxx**************xxx',\n    'method'       =\u003e 'application',\n    // 'backoff'      =\u003e false,\n    // 'cache'        =\u003e false,\n    // 'version'      =\u003e 'v3',\n    // 'enterprise'   =\u003e false,\n],\n```\n\n## Reading Repository\n\nReading a repository is as straight forward as it could be.\n\n```php\n$repository = app('github-reader')-\u003eread('rummykhan', 'github-reader');\n\ndd($repository);\n```\n\n## Getting content of a file\n\n```php\n$repository = app('github-reader')-\u003eread('rummykhan', 'github-reader');\n\n$files = $repository-\u003egetFiles();\n\n// This method will retrieve file from github\n$file = $files-\u003efirst()-\u003eretrieve();\n\ndd($file-\u003egetContent());\n```\n\n## Query Files\n\nSince files and directories are instances of `Illuminate\\Support\\Collection`, \nYou can query both files or dictionaries just like you query a `Illuminate\\Support\\Collection`\n\nThere are two ways you can query files.\n```php\n$repository = app('github-reader')\n        -\u003eread('rummykhan', 'github-reader');\n\n$file = $repository-\u003egetFiles()-\u003ewhere('name', 'LICENSE')-\u003efirst();\n\ndd($file);\n```\n**OR**\n\nTo query in Files just add `InFiles` to all the collection methods.\n```php\n$repository = app('github-reader')\n        -\u003eread('rummykhan', 'github-reader');\n\n$file = $repository-\u003ewhereInFiles('name', 'LICENSE')-\u003efirst();\n\ndd($file);\n\n```\n\n## Query Directories\n```php\n$repository = app('github-reader')\n        -\u003eread('rummykhan', 'github-reader');\n\n$dictionary = $repository-\u003egetDirectories()-\u003ewhere('name', 'src')-\u003efirst();\n\ndd($dictionary);\n```\n\n**OR**\n\nTo query in Dictionaries just add `InDictionaries` to all the Collection methods.\n\n```php\n$repository = app('github-reader')\n        -\u003eread('rummykhan', 'github-reader');\n\n$dictionary = $repository-\u003ewhereInDictionaries('name', 'src')-\u003efirst();\n\ndd($dictionary);\n```\n\n## Find a file in repository\n\nSince the structure of each item either File/Directory in the repository is like below.\n```bash\nname: \"LICENSE\"\npath: \"LICENSE\"\nsha: \"c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d\"\nsize: 1110\nurl: \"https://api.github.com/repos/rummykhan/github-reader/contents/LICENSE?ref=master\"\nhtml_url: \"https://github.com/rummykhan/github-reader/blob/master/LICENSE\"\ngit_url: \"https://api.github.com/repos/rummykhan/github-reader/git/blobs/c8a38eeec1767ff114eaf7caf5cda6d0a7f8f33d\"\ndownload_url: \"https://raw.githubusercontent.com/rummykhan/github-reader/master/LICENSE\"\ntype: \"file\"\n```\n\nWe can find any all matching directory/files recursively.\n\n```php\n$repository = app('github-reader')\n        -\u003eread('rummykhan', 'github-reader');\n\n$found = $repository-\u003efind('type', 'file');\n\ndd($found);\n```\n\nThird parameter in the find is to find recursively\n\n```php\n$repository = app('github-reader')\n        -\u003eread('rummykhan', 'github-reader');\n\n$found = $repository-\u003efind('name', 'File.php', true);\n\ndd($found);\n```\n\nThis `find` method will return a collection.\n\n\n## Available Methods\n\n### 1. GithubReader\\RepositoryReader \n\n```php\n\n$reader = app('github-reader')\n```\n\n| Name                                          | Purpose |\n| ----------------------------------------------------------- |-------------|\n| `init($organization, $repositoryName, $connection = null)` | Initialize the repository with organization/user and repository name. |\n| `getConnection()`      \t\t\t\t\t\t\t\t\t| Getter for connection. |\n| `setConnection(string $connection)` \t\t\t\t\t\t| Set the connection.|\n| `getOrganization()` \t\t\t\t\t\t\t\t\t\t| Getter for Organization. |\n| `setOrganization(string $organization)` \t\t\t\t\t| Setter for organization.|\n| `getRepositoryName()` \t\t\t\t\t\t\t\t\t| Getter for repository name. |\n| `setRepositoryName($repositoryName)` \t\t\t\t\t\t| Setter for repository name. |\n| `read($organization = null, $repositoryName = null, $connection = null)` | read a repository completely. |\n| `readPath($path = null)` \t\t\t\t\t\t\t\t\t| Read only certain path of the repository. |\n\nTo only use read path.\n\n```php\n$directory = app('github-reader')\n\t-\u003esetOrganization('rummykhan')\n\t-\u003esetRepositoryName('github-reader')\n\t-\u003ereadPath('src');\n```\n\n### 2. GithubReader\\Github\\Directory Or Repository \n\n```php\n$repository = app('github-reader')-\u003eread('rummykhan','github-reader');\n ```\n\n| Name                                          | Purpose |\n| --------------------------------------------- |-------------|\n| `getFiles()`     \t\t\t\t\t\t\t\t| Get all files in that directory. |\n| `getDirectories()`      \t\t\t\t\t\t| Get all directories in that directory. |\n| `listAll()` \t\t\t\t\t\t\t\t\t| Get all files and directories in that directory.|\n| `retrieve()` \t\t\t\t\t\t\t\t\t| Alias of `listAll()`. |\n| `find($key, $name, $all = true)` \t\t\t\t| Find in all files and directories if `$all=true` it will find recursively.|\n| `findDirectory($key, $name, $all = false)` \t| Find in directoris and if `$all=true` it will find recursively. |\n| `findFile($key, $name, $all = false)` \t\t| Find in files and if `$all=true` it will find recursively.      |\n| `toArray()` \t\t\t\t\t\t\t\t\t| Convert the object to array representation. |\n| `toJson($options = 0)` \t\t\t\t\t\t| Convert the object to JSON representation. |\n\n### 3. GithubReader\\Github\\File\n\n```php\n$repository = app('github-reader')-\u003eread('rummykhan','github-reader');\n\n$file = $repository-\u003egetFiles()-\u003efirst();\n```\n\n| Name                                          | Purpose |\n| --------------------------------------------- |-------------|\n| `retrieve()` \t\t\t\t\t\t\t\t\t| It will give you instance of `Github\\Github\\FileContent`. |\n\n### 4. GithubReader\\Github\\FileContent\n\n```php\n$repository = app('github-reader')-\u003eread('rummykhan','github-reader');\n$file = $repository-\u003egetFiles()-\u003efirst();\n$fileContent = $file-\u003eretrieve();\n```\n| Name                                          | Purpose |\n| --------------------------------------------- |-------------|\n| `getContent()` \t\t\t\t\t\t\t    | It will give content of file in plain text. |\n\n### Contact\n[rehan_manzoor@outlook.com](mailto://rehan_manzoor@outlook.com)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frummykhan%2Fgithub-reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frummykhan%2Fgithub-reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frummykhan%2Fgithub-reader/lists"}