Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Github Laravel Package

graham-campbell/github

Laravel bridge to the KnpLabs PHP GitHub API. Provides a configurable GitHub client via a manager, with Laravel-friendly service container integration, facades, and multi-connection support for GitHub authentication and requests.

View on GitHub
Deep Wiki
Context7

GitHub Is A GitHub Bridge For Laravel

Frequently asked questions about Github
How do I install Laravel GitHub API bridge for my Laravel 11 project?
Run `composer require graham-campbell/github` to install the package. Laravel 10–13 auto-discovers the service provider, so no manual registration is needed. For older versions (Laravel 5.5+), add `GrahamCampbell\GitHub\GitHubServiceProvider::class` to `config/app.php`.
Which authentication methods does this package support for GitHub API access?
The package supports five authentication methods: application (OAuth), JWT, none (public data), private (key-based), and token (personal/access tokens). Configure your preferred method in `config/github.php` after publishing the config with `php artisan vendor:publish --provider="GrahamCampbell\GitHub\GitHubServiceProvider"`.
Can I use multiple GitHub connections (e.g., personal + org accounts) in one Laravel app?
Yes, the package leverages Laravel Manager for multi-connection support. Define connections in `config/github.php` (e.g., `connections.alternative`) and switch between them using `GitHub::connection('alternative')->me()`. This is ideal for CI/CD pipelines or tenant-specific GitHub APIs.
How do I secure sensitive GitHub credentials like private keys or tokens?
Store credentials in your `.env` file (e.g., `GITHUB_PRIVATE_KEY`, `GITHUB_TOKEN`) and reference them in `config/github.php` using Laravel’s `env()` helper. Avoid hardcoding secrets in config files. For production, consider using Laravel Forge, AWS Secrets Manager, or HashiCorp Vault.
Does this package handle GitHub API rate limits, and how can I optimize performance?
The package includes optional HTTP caching via `graham-campbell/bounded-cache` to reduce API calls. Enable it in `config/github.php` and set TTLs (e.g., `5m` for repos, `1h` for user profiles). For burst traffic, implement exponential backoff using KnpLabs/php-github-api’s built-in retry logic or upgrade to GitHub Enterprise.
How do I test GitHub API interactions in PHPUnit without hitting real endpoints?
Use Mockery or Laravel’s HTTP testing tools to mock the `GrahamCampbell\GitHub\GitHubManager` facade. For VCR-style testing, integrate `vcr/vcr.php` to record and replay API responses. Example: `GitHub::shouldReceive('me')->andReturn($mockUser)`. Test authentication failures by simulating expired tokens or 403 errors.
What Laravel and PHP versions are officially supported, and how do I upgrade?
The package supports Laravel 10–13 and PHP 8.1–8.5. Check the [changelog](https://github.com/GrahamCampbell/Laravel-GitHub/blob/master/CHANGELOG.md) for breaking changes (e.g., v9.0 dropped Laravel 5 support). Upgrade by updating `composer.json`, running `composer update`, and testing in staging. Use `php artisan vendor:publish` to republish config if needed.
How do I handle GitHub API errors like 403 Forbidden or 429 Too Many Requests?
Wrap API calls in try-catch blocks to handle exceptions (e.g., `GrahamCampbell\GitHub\Exceptions\HttpException`). Extend the facade or create a custom wrapper to log errors or retry failed requests. For rate limits, use the package’s caching layer or implement a queue-based retry system with `laravel-queue`.
Is there a way to customize the GitHub API client or add endpoints not covered by KnpLabs/php-github-api?
Yes, you can access the underlying KnpLabs client via `GitHub::connection()->getClient()`. Use it to call custom endpoints or extend functionality. Example: `$client = GitHub::connection()->getClient(); $client->api('custom')->endpoint($params)`. Always test custom endpoints thoroughly, as they may break across GitHub API updates.
What are the alternatives to this package, and why should I choose Laravel GitHub?
Alternatives include raw KnpLabs/php-github-api or third-party libraries like `spatie/laravel-github-api`. Laravel GitHub stands out for its Laravel-native integration (facades, service container, multi-connection support), caching layer, and seamless authentication handling. It’s ideal for developers who want a production-ready, opinionated solution without reinventing the wheel.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor