php-github-api

repository·master·Indexed 24 days ago

https://github.com/knplabs/php-github-api

An Object-Oriented PHP wrapper for the GitHub API supporting both v3 (REST) and v4 (GraphQL). It provides a comprehensive interface for managing repositories, issues, pull requests, GitHub Actions, organization roles, and enterprise settings. The library is decoupled from HTTP clients via HTTPlug, supports PSR-6 caching to manage rate limits, and requires PHP 7.2.5 or higher for version 3.x.

Tokens
46.1K
Snippets
293
Records
408
Agent score
80%

What's inside php-github-api

  1. Overview of php-github-api capabilities

    master

    The php-github-api library provides a comprehensive PHP interface for interacting with both GitHub REST API v3 and GraphQL API v4. It supports a wide range of GitHub features including:

    • Core GitHub Data: Repositories, Issues, Pull Requests, Commits, Gists, and Users.
    • Git Data: Low-level Git objects like Blobs, Trees, Commits, References, and Tags.
    • Organization & Enterprise Management: Managing members, teams, organization roles, and enterprise-level secret scanning alerts.
    • GitHub Actions & Workflows: Interacting with workflows, workflow runs, jobs, artifacts, secrets, and variables.
    • CI/CD & Deployment: Managing deployments, environments, and check runs/suites.
    • Search & Discovery: Searching across GitHub resources.
    • Advanced Features: Pagination support, response caching, and the ability to request any arbitrary route.
  2. Requirements and Architecture for v3.x

    master

    The 3.x major version introduced several significant architectural changes:

    • Minimum PHP Version: Requires PHP 7.2.5 or higher (supports PHP 8).
    • HTTP Client Standard: Uses PSR-18 client implementation and PSR-17 for request/response factories.
    • HTTP Plug: Requires httplug/httplug version ^2.0.
    • Pagination: The pagination logic was re-worked to ensure that API classes are no longer mutated during the pagination process.
  3. Authenticate for Enterprise Admin tasks

    master
    Certain Enterprise API endpoints, specifically those related to Admin Stats, License, and User Administration, require GitHub Enterprise site administrator privileges. Additionally, Management Console API endpoints require access via the Management Console password.
  4. Access the Repo / Cards API (Early Access)

    master

    The Cards API is currently in Early Access. To use it, you must provide a custom media type in the Accept header of your requests.

    This API is available for both repositories and organizations. For repositories, use the repo API identifier. For organizations, use the org_projects API identifier. The syntax for accessing columns and cards is identical for both: $client->api('repo')->projects()->columns()->cards() or $client->api('org_projects')->columns()->cards().

    $client->api('repo')->projects()->columns()->cards()->configure();
  5. Access Organization-related APIs

    master

    The organizations API wraps the GitHub Organization API and provides access to organization-specific resources. In addition to standard organization endpoints, it provides access to:

    • Members API: For managing and viewing organization members.
    • Teams API: For managing and viewing organization teams.
  6. Use the Applications API to manage GitHub App installations

    master
    The apps API resource allows you to interact with the GitHub Applications API. You can use it to manage installation tokens, inspect installations, and control repository access for your GitHub App.
  7. Understand Pull Request Review Comments

    master

    Review Comments are specific to a portion of the unified diff within a Pull Request. They are distinct from:

    • Commit Comments: Applied directly to a commit, outside of the Pull Request view.
    • Issue Comments: General comments that do not reference a specific portion of the unified diff.

    This API wraps the GitHub PR Review Comments API. Note that new comments are automatically assigned to the authenticated user.

  8. Migrate ResultPager authentication constants in v4.0

    master
    When upgrading to version 4.0, the authentication constants on the Github\Client class are deprecated. You should switch to using the Github\AuthMethod class constants instead to specify your authentication method.
  9. Use a custom HTTP client with php-github-api

    master

    The library is decoupled from specific HTTP clients using HTTPlug. If you want to use a different client, such as symfony/http-client with nyholm/psr7, install them via Composer and then initialize the client using Client::createWithHttpClient().

    use Github\Client;
    use Symfony\Component\HttpClient\HttplugClient;
    
    $client = Client::createWithHttpClient(new HttplugClient());