{"id":16272562,"url":"https://github.com/ApxSnowflake/git-repos","last_synced_at":"2025-10-29T14:31:03.979Z","repository":{"id":57015024,"uuid":"167740552","full_name":"lilessam/git-repos","owner":"lilessam","description":"Laravel simple API to access users Github and Bitbucket repositories.","archived":false,"fork":false,"pushed_at":"2023-10-03T15:24:34.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-22T05:28:42.388Z","etag":null,"topics":["bitbucket-api","github-api","laravel","php7"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lilessam.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-26T21:24:38.000Z","updated_at":"2024-05-16T15:17:30.000Z","dependencies_parsed_at":"2024-11-05T02:41:44.085Z","dependency_job_id":null,"html_url":"https://github.com/lilessam/git-repos","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":"0.19999999999999996","last_synced_commit":"d06a113a74f53100d13992139877b5e859f00798"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilessam%2Fgit-repos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilessam%2Fgit-repos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilessam%2Fgit-repos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilessam%2Fgit-repos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lilessam","download_url":"https://codeload.github.com/lilessam/git-repos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238838865,"owners_count":19539272,"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":["bitbucket-api","github-api","laravel","php7"],"created_at":"2024-10-10T18:18:14.807Z","updated_at":"2025-10-29T14:30:58.680Z","avatar_url":"https://github.com/lilessam.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/a7med3essam"],"categories":[],"sub_categories":[],"readme":"## Laravel Git Repos\nThis package provides simplified API to access users Github \u0026 Bitbucket public and private repositories and download their contents as zip files.\n\n## Support Me\n[Buy Me A Coffee](https://www.buymeacoffee.com/a7med3essam)\n\n### Requirements\n- PHP \u003e= 7.1\n- `illuminate/support` ~5.0\n- `bitbucket/client` ^1.1\n- `knplabs/github-api`  ^2.10\n\n### Installation\n1- `composer require lilessam/git-repos dev-master`\n\n2- Add `Lilessam\\Git\\GitServiceProvider::class` to `config/app.php`\n\n3- Run `php artisan vendor:publish --provider='Lilessam\\Git\\GitServiceProvider`\n\n\nThe package assumes you have already your mechanism to authenticate the users with Bitbucket and Github.\n\nI'd highly recommend using `laravel/socialite` package as it's pretty easy and already have Github and Bitbucket drivers.\n\nPlease remember when you authenticate the users using Bitbucket to store the refresh token. You'll receive this as an attribute of Laravel Socialte User.\n\n```PHP\n/**\n * Obtain the user information from Bitbucket.\n *\n * @return \\Illuminate\\Http\\RedirectResponse\n */\npublic function handleProviderCallback()\n{\n    $socialiteUser = Socialite::driver('bitbucket')-\u003euser();\n\n    $user = User::registerUsingBitbucket($socialiteUser);\n\n    $user-\u003esetBitbucketTokens($socialiteUser-\u003etoken, $socialiteUser-\u003erefreshToken);\n\n    Auth::login($user);\n\n    return redirect($this-\u003eredirectTo);\n}\n```\n\nSo, You'll need to write four static functions somewhere  and specify them in `config/git.php`\n\n1- `github.get_token_closure`\nA callback that will return the authenticated user Github access token.\n\n```PHP\n/**\n * Get Github token for the needed session.\n *\n * @return string\n */\npublic static function getGithubToken()\n{\n    return Auth::user()-\u003e{static::GITHUB_TOKEN_COLUMN};\n}\n```\n\n2- `bitbucket.get_token_closure`\nA callback that will return the authenticated user Bitbucket access token.\n\n```PHP\n/**\n * Get Bitbucket token for the needed session.\n *\n * @return string\n */\npublic static function getBitbucketToken()\n{\n    return Auth::user()-\u003e{static::BITBUCKET_TOKEN_COLUMN};\n}\n```\n\n3- `bitbucket.refresh_token_closure`\nA callback that returns the Bitbucket refresh token of the authenticated user.\n\n```PHP\n/**\n * Get Bitbucket refresh token and return it for Git service provider.\n *\n * @return string\n */\npublic static function getBitbucketRefreshToken()\n{\n    return Auth::user()-\u003e{static::BITBUCKET_REFRESH_TOKEN_COLUMN};\n}\n```\n\n4- `bitbucket.update_token_closure`\nA callback that will be used to update the Bitbcuket access token. It will receive one parameter.\n\n```PHP\n/**\n * Update the Bitbucket access token in storage.\n *\n * @param string $token\n * @return void\n */\npublic static function updateBitbucketToken($token)\n{\n    Auth::user()-\u003eupdate([static::BITBUCKET_TOKEN_COLUMN =\u003e $token]);\n}\n\n```\n\n### Usage\n\n1- Get user Github or Bitbucket email.\n```PHP\n// Default driver | Can be changed from config/git.php\ngit()-\u003eemail();\n\n// Github email\ngit()-\u003edriver('github')-\u003eemail();\n\n// Bitbucket email\ngit()-\u003edriver('bitbucket')-\u003eemail();\n```\n\n2- Get user repositories.\n```PHP\n// Default driver | Can be changed from config/git.php\ngit()-\u003erepos();\n\n// Github email\ngit()-\u003edriver('github')-\u003erepos();\n\n// Bitbucket email\ngit()-\u003edriver('bitbucket')-\u003erepos();\n```\n\n3- Get specific repository info.\n```PHP\n$repo = git()-\u003erepos()-\u003efirst(function  ($repo)  {\n    return  $repo-\u003eid  ==  'lilessam/git-repos';\n});\n\necho $repo-\u003eid; // 'lilessam/git-repos'\necho $repo-\u003ename; // 'git-repos'\necho $repo-\u003eurl; // 'https://github.com/lilessam/git-repos'\n```\n\n4- Download repository.\n```PHP\n$repo = git()-\u003erepos()-\u003efirst(function  ($repo)  {\n    return  $repo-\u003eid  ==  'lilessam/git-repos';\n});\n$repo-\u003edownload('zip');\n// OR\n$repo-\u003edownload('tar');\n```\nI'm planning to add features to get more details for each repository but the main feature meant was to download the repository contents.\n\nPlease feel free to create PR to add more features.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FApxSnowflake%2Fgit-repos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FApxSnowflake%2Fgit-repos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FApxSnowflake%2Fgit-repos/lists"}