PHPackages                             lilessam/git-repos - 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. lilessam/git-repos

ActiveLibrary[API Development](/categories/api)

lilessam/git-repos
==================

Simplified API to access users Github &amp; Bitbucket repositories.

24PHP

Since Oct 3Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Git Repos
-----------------

[](#laravel-git-repos)

This package provides simplified API to access users Github &amp; Bitbucket public and private repositories and download their contents as zip files.

Support Me
----------

[](#support-me)

[Buy Me A Coffee](https://www.buymeacoffee.com/a7med3essam)

### Requirements

[](#requirements)

- PHP &gt;= 7.1
- `illuminate/support` ~5.0
- `bitbucket/client` ^1.1
- `knplabs/github-api` ^2.10

### Installation

[](#installation)

1- `composer require lilessam/git-repos dev-master`

2- Add `Lilessam\Git\GitServiceProvider::class` to `config/app.php`

3- Run `php artisan vendor:publish --provider='Lilessam\Git\GitServiceProvider`

The package assumes you have already your mechanism to authenticate the users with Bitbucket and Github.

I'd highly recommend using `laravel/socialite` package as it's pretty easy and already have Github and Bitbucket drivers.

Please remember when you authenticate the users using Bitbucket to store the refresh token. You'll receive this as an attribute of Laravel Socialte User.

```
/**
 * Obtain the user information from Bitbucket.
 *
 * @return \Illuminate\Http\RedirectResponse
 */
public function handleProviderCallback()
{
    $socialiteUser = Socialite::driver('bitbucket')->user();

    $user = User::registerUsingBitbucket($socialiteUser);

    $user->setBitbucketTokens($socialiteUser->token, $socialiteUser->refreshToken);

    Auth::login($user);

    return redirect($this->redirectTo);
}
```

So, You'll need to write four static functions somewhere and specify them in `config/git.php`

1- `github.get_token_closure`A callback that will return the authenticated user Github access token.

```
/**
 * Get Github token for the needed session.
 *
 * @return string
 */
public static function getGithubToken()
{
    return Auth::user()->{static::GITHUB_TOKEN_COLUMN};
}
```

2- `bitbucket.get_token_closure`A callback that will return the authenticated user Bitbucket access token.

```
/**
 * Get Bitbucket token for the needed session.
 *
 * @return string
 */
public static function getBitbucketToken()
{
    return Auth::user()->{static::BITBUCKET_TOKEN_COLUMN};
}
```

3- `bitbucket.refresh_token_closure`A callback that returns the Bitbucket refresh token of the authenticated user.

```
/**
 * Get Bitbucket refresh token and return it for Git service provider.
 *
 * @return string
 */
public static function getBitbucketRefreshToken()
{
    return Auth::user()->{static::BITBUCKET_REFRESH_TOKEN_COLUMN};
}
```

4- `bitbucket.update_token_closure`A callback that will be used to update the Bitbcuket access token. It will receive one parameter.

```
/**
 * Update the Bitbucket access token in storage.
 *
 * @param string $token
 * @return void
 */
public static function updateBitbucketToken($token)
{
    Auth::user()->update([static::BITBUCKET_TOKEN_COLUMN => $token]);
}
```

### Usage

[](#usage)

1- Get user Github or Bitbucket email.

```
// Default driver | Can be changed from config/git.php
git()->email();

// Github email
git()->driver('github')->email();

// Bitbucket email
git()->driver('bitbucket')->email();
```

2- Get user repositories.

```
// Default driver | Can be changed from config/git.php
git()->repos();

// Github email
git()->driver('github')->repos();

// Bitbucket email
git()->driver('bitbucket')->repos();
```

3- Get specific repository info.

```
$repo = git()->repos()->first(function  ($repo)  {
    return  $repo->id  ==  'lilessam/git-repos';
});

echo $repo->id; // 'lilessam/git-repos'
echo $repo->name; // 'git-repos'
echo $repo->url; // 'https://github.com/lilessam/git-repos'
```

4- Download repository.

```
$repo = git()->repos()->first(function  ($repo)  {
    return  $repo->id  ==  'lilessam/git-repos';
});
$repo->download('zip');
// OR
$repo->download('tar');
```

I'm planning to add features to get more details for each repository but the main feature meant was to download the repository contents.

Please feel free to create PR to add more features.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![ApxSnowflake](https://avatars.githubusercontent.com/u/8589158?v=4)](https://github.com/ApxSnowflake "ApxSnowflake (6 commits)")

---

Tags

bitbucket-apigithub-apilaravelphp7

### Embed Badge

![Health badge](/badges/lilessam-git-repos/health.svg)

```
[![Health](https://phpackages.com/badges/lilessam-git-repos/health.svg)](https://phpackages.com/packages/lilessam-git-repos)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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