Skip to content

Advanced GitHub API integration for Laravel 12 with typed DTOs and Collections.

License

Notifications You must be signed in to change notification settings

akira-io/laravel-github

Repository files navigation

Laravel GitHub

A Laravel 12+ package to interact with the GitHub REST and GraphQL APIs using a strongly-typed, collection-friendly interface.

This package provides:

  • Fully typed DTOs for common GitHub resources (users, repos, issues, PRs, actions, packages, dependabot, etc.).
  • High-level service GitHubManager with caching and rate limiting.
  • Artisan commands to quickly query GitHub resources.
  • 100% test coverage with Pest and static analysis with Larastan.

Installation

composer require akira/laravel-github
php artisan vendor:publish --tag=config --provider="Akira\\GitHub\\GitHubServiceProvider"

Configuration

return [
    'token' => env('GITHUB_TOKEN', null),
    'cache' => [
        'ttl' => 300,
        'prefix' => 'github:',
        'ttls' => [
            'issues' => 60,
            'pulls' => 60,
            'releases' => 300,
        ],
    ],
    'pagination' => ['per_page' => 30],
    'rate_limiter' => ['max' => 60, 'decay_seconds' => 60],
    'events' => true,
];

Usage Examples

Users

$user = GitHub::user('octocat');
$repos = GitHub::userRepos('octocat');

Repositories

$repo = GitHub::repo('akira', 'hunter');

Issues

$issues = GitHub::issues('akira', 'hunter');
$new = GitHub::createIssue('akira', 'hunter', 'Bug', 'Description');
GitHub::commentOnIssue('akira', 'hunter', $new->number, 'Working on it!');

Pull Requests

$prs = GitHub::pulls('akira', 'hunter');

Releases

$releases = GitHub::releases('akira', 'hunter');

Organizations and Teams

$org = GitHub::organization('akira-io');
$repos = GitHub::orgRepos('akira-io');
$teams = GitHub::teams('akira-io');

Gists

$gists = GitHub::gists('octocat');
$gist = GitHub::gist('123');

GitHub Actions

$runs = GitHub::actionsWorkflowRuns('akira', 'hunter');
GitHub::actionsRerun('akira', 'hunter', $runs[0]->id);
GitHub::actionsCancel('akira', 'hunter', $runs[0]->id);
GitHub::actionsDownloadArtifact('akira', 'hunter', $runs[0]->id, storage_path('artifact.zip'));

Checks

$checks = GitHub::checksForRef('akira', 'hunter', 'main');

Packages

$packages = GitHub::orgPackages('akira-io', 'container');

Dependabot Alerts

$alerts = GitHub::dependabotAlerts('akira', 'hunter');

Projects V2 (GraphQL)

$projects = GitHub::projectsV2('akira');

Webhook Verification

$isValid = GitHub::verifyWebhookSignature($secret, $payload, $signature);

Artisan Commands

php artisan github:user octocat
php artisan github:repo akira hunter
php artisan github:issue:list akira hunter
php artisan github:pr:list akira hunter
php artisan github:actions:runs akira hunter --per_page=5

πŸ“š Documentation

This package also includes a dedicated docs/ folder with extended details:


Project Structure

laravel-github/
β”œβ”€β”€ src/                # Package source code
β”œβ”€β”€ tests/              # Pest test suite
β”œβ”€β”€ docs/               # Extended documentation
β”œβ”€β”€ README.md           # Quick start & inline docs
β”œβ”€β”€ composer.json
└── pest.php / phpunit.xml

Contributing

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Run tests (composer test)
  4. Ensure code style and static analysis pass (composer analyse)
  5. Submit a PR

License

MIT

About

Advanced GitHub API integration for Laravel 12 with typed DTOs and Collections.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages